Skip to content

Commit

Permalink
Merge pull request #618 from RockefellerArchiveCenter/development
Browse files Browse the repository at this point in the history
Make extent inheritance optional
  • Loading branch information
helrond authored Sep 13, 2024
2 parents 9a956b0 + c155811 commit 0a7300c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion merger/mergers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from requests.exceptions import ConnectionError

from pisces import settings

from .helpers import (ArchivesSpaceHelper, MissingArchivalObjectError,
add_group, closest_creators, closest_parent_value,
combine_references, handle_cartographer_reference,
Expand Down Expand Up @@ -202,7 +204,7 @@ def get_archivesspace_data(self, object, object_type):
if not object.get("extents"):
extent_data = self.parse_instances(object["instances"])
if object_type == "archival_object_collection" and not extent_data:
extent_data = closest_parent_value(object, "extents")
extent_data = settings.INHERIT_EXTENT and [{'value': None, "type": None}] or closest_parent_value(object, "extents")
data["extents"] = extent_data
if object_type == "archival_object_collection":
data["linked_agents"] = closest_creators(object)
Expand Down
1 change: 1 addition & 0 deletions pisces/config.py.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ TERM_SCHEMA = "${TERM_SCHEMA}"
NOTIFY_EMAIL = ${NOTIFY_EMAIL}
NOTIFY_TEAMS = ${NOTIFY_TEAMS}
TEAMS_URL = "${TEAMS_URL}"
INHERIT_EXTENT = ${INHERIT_EXTENT}
1 change: 1 addition & 0 deletions pisces/config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ TERM_SCHEMA = "term.json" # Filename for schema against which transformed terms
NOTIFY_EMAIL = True # deliver error messages via email (boolean)
NOTIFY_TEAMS = False # deliver error message via Microsoft Teams (boolean)
TEAMS_URL = "https://teams-url.com" # URL for Incoming Webhook Connector in Microsoft Teams Channel
INHERIT_EXTENT = True # Configure whether extents are inherited down a collection hierarchy (boolean)
2 changes: 2 additions & 0 deletions pisces/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,5 @@
MANIFEST_BASEURL = config.MANIFEST_BASEURL

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
# Data attribute inheritance configuration
INHERIT_EXTENT = config.INHERIT_EXTENT
6 changes: 3 additions & 3 deletions transformer/resources/rac.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class Date(odin.Resource):

class Extent(odin.Resource):
"""Records the size of an aggregation of archival records."""
value = odin.StringField()
type = odin.StringField()
value = odin.StringField(null=True)
type = odin.StringField(null=True)


class FileObject(odin.Resource):
Expand Down Expand Up @@ -147,7 +147,7 @@ class Object(BaseResource):
category = odin.StringField(default="collection")
dates = odin.ArrayOf(Date)
languages = odin.ArrayOf(Language)
extents = odin.ArrayOf(Extent)
extents = odin.ArrayOf(Extent, null=True)
notes = odin.ArrayOf(Note)
people = odin.ArrayOf(AgentReference)
organizations = odin.ArrayOf(AgentReference)
Expand Down
6 changes: 3 additions & 3 deletions transformer/resources/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ class SourceDigitalObject(odin.Resource):

class SourceExtent(odin.Resource):
"""Records the size of an aggregation of archival records."""
number = odin.StringField()
number = odin.StringField(null=True)
container_summary = odin.StringField(null=True)
portion = odin.StringField(choices=(('whole', 'Whole'), ('part', 'Part'))),
extent_type = odin.StringField()
extent_type = odin.StringField(null=True)


class SourceExternalId(odin.Resource):
Expand Down Expand Up @@ -224,7 +224,7 @@ class Meta:
)

dates = odin.ArrayOf(SourceDate)
extents = odin.ArrayOf(SourceExtent)
extents = odin.ArrayOf(SourceExtent, null=True)
external_ids = odin.ArrayOf(SourceExternalId)
group = odin.DictAs(SourceGroup)
jsonmodel_type = odin.StringField(choices=COMPONENT_TYPES)
Expand Down

0 comments on commit 0a7300c

Please sign in to comment.