Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions funidata_utils/schemas/sisu/attainment.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,6 @@ def date_as_isoformat(self, val: datetime.date, _info):
return None
return val.isoformat()

@field_validator('attainmentDate')
def attainment_date_valid(cls, val: datetime.date, _info):
if val > datetime.date.today():
raise ValueError("Attainment date must not be in the future")

return val

@model_validator(mode='after')
def valid_primary_attainment(self):
if self.documentState == 'DELETED' or not self.primary:
Expand Down Expand Up @@ -183,6 +176,13 @@ class CourseUnitAttainment(Attainment):
evaluationCriteria: LocalizedString | None = None
assessmentItemAttainmentIds: list[str] | None = None

@field_validator('attainmentDate')
def attainment_date_valid(cls, val: datetime.date, _info):
if val > datetime.date.today():
raise ValueError("Attainment date must not be in the future")

return val


class CustomCourseUnitAttainment(Attainment):
type: Literal['CustomCourseUnitAttainment'] = 'CustomCourseUnitAttainment'
Expand All @@ -192,6 +192,13 @@ class CustomCourseUnitAttainment(Attainment):
code: str
customStudyDraftId: str | None = None

@field_validator('attainmentDate')
def attainment_date_valid(cls, val: datetime.date, _info):
if val > datetime.date.today():
raise ValueError("Attainment date must not be in the future")

return val


class CustomModuleAttainment(Attainment):
type: Literal['CustomModuleAttainment'] = 'CustomModuleAttainment'
Expand Down
Loading