class CostItem(odin.Resource): name = odin.StringField(null=True) code = odin.StringField(null=True) type = odin.StringField(null=True) season = odin.StringField(null=True) time = odin.StringField(null=True) cost = odin.FloatField()
class SourceDate(odin.Resource): """Records the dates associated with an aggregation of archival records.""" expression = odin.StringField(null=True) begin = odin.StringField(null=True) end = odin.StringField(null=True) date_type = odin.StringField(choices=configs.DATE_TYPE_CHOICES) label = odin.StringField(choices=configs.DATE_LABEL_CHOICES)
class Subscriber(odin.Resource): name = odin.StringField() address = odin.StringField() def __eq__(self, other): if other: return self.name == other.name and self.address == other.address
class Level2(odin.Resource): class Meta: namespace = 'odin.traversal' name = odin.StringField() label = odin.StringField(null=True) level3s = odin.ListOf(Level3)
class Error(odin.Resource): """ Standard error response """ status = odin.IntegerField(verbose_name="HTTP status code") code = odin.IntegerField(verbose_name="Error code") message = odin.StringField(verbose_name="End user message") developer_message = odin.StringField(verbose_name="Developer message", null=True) meta = odin.DictField(verbose_name='Error specific metadata', null=True) @classmethod def from_status(cls, status: HTTPStatus, *, code_index: int = 0, message: str = None, developer_message: str = None, meta: Any = None) -> 'Error': """ Automatically build an HTTP Response form HTTP Status code. :param status: HTTP Status code :param code_index: Unique status code index. :param message: End user message :param developer_message: Developer message :param meta: Additional error metadata """ return cls(status=status, code=(status * 100) + code_index, message=message or status.phrase, developer_message=developer_message or status.description, meta=meta)
class ArchivesSpaceDate(odin.Resource): """Dates associated with a group of archival records.""" expression = odin.StringField(null=True) begin = odin.StringField(null=True) end = odin.StringField(null=True) date_type = odin.StringField(choices=resource_configs.DATE_TYPE_CHOICES) label = odin.StringField(choices=resource_configs.DATE_LABEL_CHOICES)
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 ArchivesSpaceExtent(odin.Resource): """The extent of a group of archival records.""" number = odin.StringField() container_summary = odin.StringField(null=True) portion = odin.StringField(choices=(('whole', 'Whole'), ('part', 'Part'))) extent_type = odin.StringField( choices=resource_configs.EXTENT_TYPE_CHOICES)
class ArchivesSpaceNameBase(odin.Resource): """Base class for names. Subclassed by names specific to an agent type.""" rules = odin.StringField(default="dacs") source = odin.StringField(default="local") sort_name_auto_generate = odin.BooleanField(default=True)
class Book(odin.Resource): title = odin.StringField(name="Title") num_pages = odin.IntegerField(name="Num Pages") rrp = odin.FloatField(name="RRP") genre = odin.StringField(name="Genre", choices=( ('sci-fi', 'Science Fiction'), ('fantasy', 'Fantasy'), ('others', 'Others'), ), null=True) author = odin.StringField(name="Author") publisher = odin.StringField(name="Publisher") language = odin.StringField(name="Language", null=True) def extra_attrs(self, attrs): self.extras = attrs def __eq__(self, other): return (self.title == other.title and self.num_pages == other.num_pages and self.rrp == other.rrp and (self.genre == other.genre or (not self.genre and not other.genre)) and self.author == other.author and self.publisher == other.publisher and (self.language == other.language or (not self.language and not other.language)))
class SourceLinkedAgent(odin.Resource): """A reference to a SourceAgentFamily, SourceAgentPerson or SourceAgentCorporateEntity.""" role = odin.StringField(choices=configs.AGENT_ROLE_CHOICES) relator = odin.StringField(choices=configs.AGENT_RELATOR_CHOICES, null=True) ref = odin.StringField() type = odin.StringField() title = odin.StringField()
class ArchivesSpaceLinkedAgent(odin.Resource): """An agent linked to a group of archival records.""" role = odin.StringField( choices=resource_configs.AGENT_ROLE_CHOICES, default="creator") relator = odin.StringField( choices=resource_configs.AGENT_RELATOR_CHOICES, null=True) ref = 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 Term(BaseResource): """A controlled term. Term is a first-class entity in the RAC data model. """ category = odin.StringField(default="subject") type = odin.StringField(default="term") term_type = odin.StringField(choices=configs.TERM_TYPE_CHOICES)
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 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 User(odin.Resource): """ User resource """ id = odin.IntegerField(key=True) username = odin.StringField() name = odin.StringField() email = odin.EmailField() role = odin.StringField(choices=('a', 'b', 'c'))
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 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 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 Date(odin.Resource): """Records the dates associated with an aggregation of archival records.""" begin = odin.DateTimeField() end = odin.DateTimeField() expression = odin.StringField() type = odin.StringField(choices=configs.DATE_TYPE_CHOICES) label = odin.StringField(choices=configs.DATE_LABEL_CHOICES) source = odin.StringField(null=True, default='archivesspace', choices=configs.SOURCE_CHOICES)
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 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 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 Book(odin.Resource): title = odin.StringField(name="Title") num_pages = odin.IntegerField(name="Num Pages") rrp = odin.FloatField(name="RRP") genre = odin.StringField(name="Genre", choices=( ('sci-fi', 'Science Fiction'), ('fantasy', 'Fantasy'), ('others', 'Others'), )) author = odin.StringField(name="Author") publisher = odin.StringField(name="Publisher")
class SourceNameBase(odin.Resource): """Base class for structured representations of names. Subclassed by more specific representations SourceNameCorporateEntity, SourceNamePerson and SourceNameFamily. """ sort_name = odin.StringField() authorized = odin.BooleanField() is_display_name = odin.BooleanField() # use_dates = odin.ArrayOf(SourceStructuredDate) # TODO: account for structured and nonstructured dates rules = odin.StringField(choices=configs.NAME_RULES_CHOICES, null=True) source = odin.StringField(choices=configs.NAME_SOURCE_CHOICES, null=True)
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 User(odin.Resource): class Meta: namespace = 'tests' id = odin.IntegerField() name = odin.StringField() email = odin.EmailField(null=True, doc_text="Users email") role = odin.StringField(null=True, choices=( ('admin', 'Admin'), ('manager', 'Manage'), ('user', 'User'), ))
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 Author(odin.Resource): name = odin.StringField() country = odin.StringField(null=True) def clean(self): if self.name == "Bruce" and self.country.startswith("Australia"): raise ValidationError("No no no no") def clean_country(self, value): if value not in ["Australia", "New Zealand"]: raise ValidationError("What are ya?") return "%s!" % value def extra_attrs(self, attrs): self.extras = attrs