Skip to content

Commit

Permalink
update Findspot schema
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonjetz committed Nov 2, 2023
1 parent 42e1866 commit 423727c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions ebl/fragmentarium/application/archaeology_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ def create_excavation_plan(self, data, **kwargs) -> ExcavationPlan:


class FindspotSchema(Schema):
site = fields.Function(
lambda findspot: getattr(findspot.site, "long_name", None),
lambda value: ExcavationSite.from_name(value),
allow_none=True,
)
area = fields.String()
building = fields.String()
building_type = NameEnumField(BuildingType, data_key="buildingType")
Expand All @@ -44,14 +49,15 @@ class FindspotSchema(Schema):
plans = fields.Nested(ExcavationPlanSchema, many=True, load_default=tuple())
room = fields.String()
context = fields.String()
primary_context = fields.Boolean(data_key="primaryContext")
primary_context = fields.Boolean(
data_key="primaryContext",
allow_none=True,
)
notes = fields.String()
references = fields.Nested(ReferenceSchema, many=True, load_default=tuple())

@post_load
def create_findspot(self, data, **kwargs) -> Findspot:
data["plans"] = tuple(data["plans"])
data["references"] = tuple(data["references"])
return Findspot(**data)


Expand Down
3 changes: 2 additions & 1 deletion ebl/fragmentarium/domain/findspot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from enum import Enum, auto
from ebl.bibliography.domain.reference import Reference
from ebl.fragmentarium.domain.iso_date import DateRange
from ebl.corpus.domain.provenance import Provenance as ExcavationSite


class BuildingType(Enum):
Expand All @@ -22,6 +23,7 @@ class ExcavationPlan:

@attr.s(auto_attribs=True, frozen=True)
class Findspot:
site: Optional[ExcavationSite] = None
area: str = ""
building: str = ""
building_type: Optional[BuildingType] = None
Expand All @@ -32,4 +34,3 @@ class Findspot:
context: str = ""
primary_context: Optional[bool] = None
notes: str = ""
references: Sequence[Reference] = tuple()

0 comments on commit 423727c

Please sign in to comment.