class Group(odin.Resource): """Information about the highest-level collection containing the data object.""" category = odin.StringField() creators = odin.ArrayOf(AgentReference, null=True) dates = odin.ArrayOf(Date, null=True) identifier = odin.StringField() title = odin.StringField()
class SourceTransfer(odin.Resource): metadata = odin.DictAs(SourceMetadata) url = odin.StringField() rights_statements = odin.ArrayOf(SourceRightsStatement) resource = odin.StringField() parent = odin.StringField(null=True) linked_agents = odin.ArrayOf(SourceLinkedCreator, null=True) level = odin.StringField()
class Library(odin.Resource): name = odin.StringField() books = odin.ArrayOf(LibraryBook) subscribers = odin.ArrayOf(Subscriber, null=True) book_count = CalculatedField(lambda o: len(o.books)) class Meta: name_space = None
class SourceSubject(odin.Resource): """A topical term.""" external_ids = odin.ArrayOf(SourceExternalId) group = odin.DictAs(SourceGroup) publish = odin.BooleanField() source = odin.StringField(choices=configs.SUBJECT_SOURCE_CHOICES) terms = odin.ArrayOf(SourceTerm) title = odin.StringField() uri = odin.StringField()
class SourceArchivalObject(SourceComponentBase): """A component of a SourceResource.""" position = odin.IntegerField() ref_id = odin.StringField() component_id = odin.StringField(null=True) display_string = odin.StringField() restrictions_apply = odin.BooleanField() ancestors = odin.ArrayOf(SourceAncestor) resource = odin.DictAs(SourceRef) has_unpublished_ancestor = odin.BooleanField() instances = odin.ArrayOf(SourceInstance)
class SourceResource(SourceComponentBase): """An aggregation of records.""" position = odin.IntegerField() restrictions = odin.BooleanField() ead_id = odin.StringField(null=True) finding_aid_title = odin.StringField(null=True) finding_aid_filing_title = odin.StringField(null=True) id_0 = odin.StringField() id_1 = odin.StringField(null=True) id_2 = odin.StringField(null=True) ancestors = odin.ArrayOf(SourceAncestor, null=True) instances = odin.ArrayOf(SourceInstance)
class ArchivesSpaceRightsStatement(odin.Resource): """A machine-actionable rights statement.""" determination_date = odin.DateField(null=True) rights_type = odin.StringField() start_date = odin.DateField() end_date = odin.DateField(null=True) status = odin.StringField(null=True) other_rights_basis = odin.StringField(null=True) jurisdiction = odin.StringField(null=True) license_terms = odin.StringField(null=True) statute_citation = odin.StringField(null=True) notes = odin.ArrayOf(ArchivesSpaceNote) acts = odin.ArrayOf(ArchivesSpaceRightsStatementAct)
class Charge(odin.Resource): """A charge component of a tariff structure""" rate = odin.FloatField(null=True) rate_bands = odin.ArrayOf(RateBand, null=True) rate_schedule = odin.ArrayOf(ScheduleItem, null=True) time = odin.ObjectAs(Time, null=True) season = odin.ObjectAs(Season, null=True) type = odin.StringField(choices=CHARGE_TYPE_CHOICES, null=True, default='consumption', use_default_if_not_provided=True) meter = odin.StringField(null=True, default='electricity_imported', use_default_if_not_provided=True)
class Agent(BaseResource): """A person, family or organization who acts on or is represented in records. Agent is a first-class entity in the RAC data model. """ type = odin.StringField(default="agent") authorized_name = odin.StringField() category = odin.StringField() agent_type = odin.StringField() description = odin.StringField(null=True) dates = odin.ArrayOf(Date) notes = odin.ArrayOf(Note) people = odin.ArrayOf(AgentReference) organizations = odin.ArrayOf(AgentReference) families = odin.ArrayOf(AgentReference)
class ArchivesSpaceRightsStatementAct(odin.Resource): """Documents permissions or restrictions associated with a group of archival records.""" act_type = odin.StringField() start_date = odin.DateField() end_date = odin.DateField(null=True) restriction = odin.StringField() notes = odin.ArrayOf(ArchivesSpaceNote)
class ArchivesSpaceDigitalObject(odin.Resource): """A digital object representing a group of archival records.""" jsonmodel_type = odin.StringField(default="digital_object") publish = odin.BooleanField(default=False) title = odin.StringField() digital_object_id = odin.IntegerField() file_versions = odin.ArrayOf(ArchivesSpaceFileVersion) repository = odin.DictField(default={"ref": "/repositories/{}".format(settings.ARCHIVESSPACE['repo_id'])})
class SourceComponentBase(odin.Resource): """Base class for archival components. Subclassed by SourceArchivalObject and SourceResource. Both language and lang_material need to exist in order to accomodate ArchivesSpace API changes between v2.6 and v2.7. """ class Meta: abstract = True COMPONENT_TYPES = (('archival_object', 'Archival Object'), ('resource', 'Resource')) dates = odin.ArrayOf(SourceDate) extents = odin.ArrayOf(SourceExtent) external_ids = odin.ArrayOf(SourceExternalId) group = odin.DictAs(SourceGroup) jsonmodel_type = odin.StringField(choices=COMPONENT_TYPES) lang_materials = odin.ArrayOf(SourceLangMaterial, null=True) language = odin.StringField(null=True) level = odin.StringField() linked_agents = odin.ArrayOf(SourceLinkedAgent) notes = odin.ArrayOf(SourceNote) publish = odin.BooleanField() subjects = odin.ArrayOf(SourceRef) suppressed = odin.StringField() title = odin.StringField(null=True) uri = odin.StringField()
class SourceMetadata(odin.Resource): date_end = odin.DateTimeField() date_start = odin.DateTimeField() internal_sender_description = odin.StringField() language = odin.ArrayField() payload_oxum = odin.StringField() record_creators = odin.ArrayOf(SourceCreator) source_organization = odin.StringField() title = odin.StringField()
class ArchivesSpaceNote(odin.Resource): """A note describing a group of archival records.""" publish = odin.BooleanField(default=False) jsonmodel_type = odin.StringField() type = odin.StringField() label = odin.StringField(null=True) subnotes = odin.ArrayOf(ArchivesSpaceSubnote, null=True) content = odin.StringField(null=True) items = odin.StringField(null=True)
class Cost(odin.Resource): name = odin.StringField(null=True) code = odin.StringField(null=True) items = odin.ArrayOf(CostItem) @odin.calculated_field def cost(self): cost = 0.0 for cost_item in self.items: cost += cost_item.cost return cost
class Note(odin.Resource): """A human-readable note. Notes contain one or more Subnotes. """ type = odin.StringField(choices=configs.NOTE_TYPE_CHOICES) title = odin.StringField(null=True) source = odin.StringField(null=True, default='archivesspace', choices=configs.SOURCE_CHOICES) subnotes = odin.ArrayOf(Subnote)
class ArchivesSpaceAccession(ArchivesSpaceComponentBase): """Groups of records as received from record creators.""" accession_date = odin.StringField() access_restrictions_note = odin.StringField(null=True) acquisition_type = odin.StringField() content_description = odin.StringField() general_note = odin.StringField(null=True) id_0 = odin.StringField() id_1 = odin.StringField() related_resources = odin.ArrayOf(ArchivesSpaceRef) use_restrictions_note = odin.StringField(null=True)
class SourceAgentBase(odin.Resource): """A base class for agents. Subclassed by SourceAgentFamily, SourceAgentPerson and SourceAgentCorporateEntity. """ class Meta: abstract = True AGENT_TYPES = (('agent_corporate_entity', 'Organization'), ('agent_family', 'Family'), ('agent_person', 'Person')) agent_record_identifiers = odin.ArrayOf(SourceAgentRecordIdentifier, null=True) dates_of_existence = odin.ArrayField(null=True) group = odin.DictAs(SourceGroup) jsonmodel_type = odin.StringField(choices=AGENT_TYPES) notes = odin.ArrayOf(SourceNote) publish = odin.BooleanField() title = odin.StringField() uri = odin.StringField()
class SourceNote(odin.Resource): """Human-readable note. SourceNotes contain one or more SourceSubnotes. """ jsonmodel_type = odin.StringField() type = odin.StringField(null=True) label = odin.StringField(null=True) subnotes = odin.ArrayOf(SourceSubnote, null=True) content = odin.StringField(null=True) items = odin.ArrayField(null=True) publish = odin.BooleanField()
class SourceAccession(odin.Resource): title = odin.StringField() url = odin.StringField() extent_size = odin.IntegerField() extent_files = odin.IntegerField() start_date = odin.DateTimeField() end_date = odin.DateTimeField() organization = odin.StringField() rights_statements = odin.ArrayOf(SourceRightsStatement) creators = odin.ArrayOf(SourceCreator) resource = odin.StringField() accession_date = odin.StringField() access_restrictions = odin.StringField() use_restrictions = odin.StringField() acquisition_type = odin.StringField() description = odin.StringField() appraisal_note = odin.StringField(null=True) accession_number = odin.StringField(null=True) language = odin.StringField() linked_agents = odin.ArrayOf(SourceLinkedCreator, null=True) level = odin.StringField(null=True)
class Charge(odin.Resource): """A charge component of a tariff structure""" code = odin.StringField(null=True) rate = odin.FloatField(null=True) rate_bands = odin.ArrayOf(RateBand, null=True) rate_schedule = odin.ArrayOf(ScheduleItem, null=True) time = odin.ObjectAs(Time, null=True) season = odin.ObjectAs(Season, null=True) type = odin.StringField(choices=CHARGE_TYPE_CHOICES, null=True, default='consumption', use_default_if_not_provided=True) meter = odin.StringField(null=True) @odin.calculated_field def name(self): season = self.season.name if self.season else None time = self.time.name if self.time else None scheduled = 'scheduled' if self.rate_schedule else None return str(self.code or '') + str(self.type or '') + str( season or '') + str(time or '') + str(scheduled or '')
class SourceAncestor(odin.Resource): """A related SourceResource or SourceArchivalObject. SourceAncestors are parents of the current data object. Order is significant; they are listed from closest to furthest away (in other words the last ancestor will always be the top level of a collection). """ ref = odin.StringField() level = odin.StringField() order = odin.StringField(null=True) title = odin.StringField(null=True) type = odin.StringField(null=True) subjects = odin.ArrayOf(SourceRef, null=True) dates = odin.StringField(null=True)
class SourceRightsStatement(odin.Resource): rights_basis = odin.StringField() start_date = odin.DateField(null=True) end_date = odin.DateField(null=True) rights_granted = odin.ArrayOf(SourceRightsStatementAct) external_documents = odin.ArrayField(null=True) linked_agents = odin.ArrayField(null=True) basis_note = odin.StringField(null=True) copyright_status = odin.StringField(null=True) determination_date = odin.DateField(null=True) terms = odin.StringField(null=True) statute_citation = odin.StringField(null=True) other_basis = odin.StringField(null=True) jurisdiction = odin.StringField(null=True)
class Collection(BaseResource): """An aggregation of archival records. Collections contain other aggregations of records (either Objects or Collections), and may themselves be contained within another Collection. Collection is a first-class entity in the RAC data model. """ type = odin.StringField(default="collection") category = odin.StringField(default="collection") level = odin.StringField() dates = odin.ArrayOf(Date) creators = odin.ArrayOf(AgentReference) languages = odin.ArrayOf(Language) extents = odin.ArrayOf(Extent) notes = odin.ArrayOf(Note) people = odin.ArrayOf(AgentReference) organizations = odin.ArrayOf(AgentReference) families = odin.ArrayOf(AgentReference) terms = odin.ArrayOf(TermReference) ancestors = odin.ArrayOf(RecordReference, null=True) parent = odin.StringField(null=True) position = odin.IntegerField() formats = odin.ArrayField() online = odin.BooleanField(default=False)
class Object(BaseResource): """An aggregation of archival records. Objects may be contained within Collections, but do not contain other Objects or Collections. Object is a first-class entity in the RAC data model. """ type = odin.StringField(default="object") category = odin.StringField(default="collection") dates = odin.ArrayOf(Date) languages = odin.ArrayOf(Language) extents = odin.ArrayOf(Extent) notes = odin.ArrayOf(Note) people = odin.ArrayOf(AgentReference) organizations = odin.ArrayOf(AgentReference) families = odin.ArrayOf(AgentReference) terms = odin.ArrayOf(TermReference) ancestors = odin.ArrayOf(RecordReference, null=True) parent = odin.StringField() position = odin.IntegerField() formats = odin.ArrayField() online = odin.BooleanField(default=False)
class ToResource(odin.Resource): # Auto matched title = odin.StringField() count = odin.IntegerField() child = odin.ObjectAs(ChildResource) children = odin.ArrayOf(ChildResource) # Excluded excluded1 = odin.FloatField() # Mappings to_field1 = odin.StringField() to_field2 = odin.IntegerField() to_field3 = odin.IntegerField() same_but_different = odin.StringField() # Custom mappings to_field_c1 = odin.StringField() to_field_c2 = odin.StringField() to_field_c3 = odin.StringField() not_auto_c5 = odin.StringField() array_string = odin.TypedArrayField(odin.StringField()) assigned_field = odin.StringField()
class FromResource(odin.Resource): # Auto matched title = odin.StringField() count = odin.StringField() child = odin.ObjectAs(ChildResource) children = odin.ArrayOf(ChildResource) # Excluded excluded1 = odin.FloatField() # Mappings from_field1 = odin.StringField() from_field2 = odin.StringField() from_field3 = odin.IntegerField() from_field4 = odin.IntegerField() same_but_different = odin.StringField() # Custom mappings from_field_c1 = odin.StringField() from_field_c2 = odin.StringField() from_field_c3 = odin.StringField() from_field_c4 = odin.StringField() not_auto_c5 = odin.StringField() comma_separated_string = odin.StringField() # Virtual fields constant_field = odin.ConstantField(value=10)
class Book(LibraryBook): class Meta: key_field_name = 'isbn' title = odin.StringField() isbn = odin.StringField() num_pages = odin.IntegerField() rrp = odin.FloatField(default=20.4, use_default_if_not_provided=True) fiction = odin.BooleanField(is_attribute=True) genre = odin.StringField(choices=( ('sci-fi', 'Science Fiction'), ('fantasy', 'Fantasy'), ('biography', 'Biography'), ('others', 'Others'), ('computers-and-tech', 'Computers & technology'), )) published = odin.TypedArrayField(odin.DateTimeField()) authors = odin.ArrayOf(Author, use_container=True) publisher = odin.DictAs(Publisher, null=True) def __eq__(self, other): if other: return vars(self) == vars(other) return False
class ArchivesSpaceComponentBase(odin.Resource): """Base class for components, which describe groups of archival records.""" class Meta: abstract = True COMPONENT_TYPES = ( ('archival_object', 'Archival Object'), ('accession', 'Accession'), ) dates = odin.ArrayOf(ArchivesSpaceDate) extents = odin.ArrayOf(ArchivesSpaceExtent) external_ids = odin.ArrayOf(ArchivesSpaceExternalId) instances = odin.ArrayField(null=True) jsonmodel_type = odin.StringField(choices=COMPONENT_TYPES) lang_materials = odin.ArrayOf(ArchivesSpaceLangMaterial, null=True) linked_agents = odin.ArrayOf(ArchivesSpaceLinkedAgent) notes = odin.ArrayOf(ArchivesSpaceNote) publish = odin.BooleanField(default=False) repository = odin.DictField(default={"ref": "/repositories/{}".format(settings.ARCHIVESSPACE['repo_id'])}) rights_statements = odin.ArrayOf(ArchivesSpaceRightsStatement) title = odin.StringField(null=True) uri = odin.StringField()
class ArchivesSpaceAgentPerson(odin.Resource): """People associated with groups of archival records.""" agent_type = odin.StringField(default="agent_person") names = odin.ArrayOf(ArchivesSpaceNamePerson)