changed times of activities
This commit is contained in:
parent
b72842dda7
commit
43ee692609
@ -4,7 +4,7 @@ from pydantic import model_validator
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from .communication import CommunicationModel
|
from .communication import CommunicationModel
|
||||||
from .submodels import ActivityPaymentInfo
|
from .submodels import ActivityPaymentInfo, Occurrence
|
||||||
from .enums import CommunicationCategory
|
from .enums import CommunicationCategory
|
||||||
|
|
||||||
from fiber_package.refs import SignupRefList
|
from fiber_package.refs import SignupRefList
|
||||||
@ -16,14 +16,17 @@ from fiber_package.signup.element.form_base_question import FormBaseQuestion
|
|||||||
|
|
||||||
from fiber_package.signup.element.types import FormElementUnion, FormTextUnion
|
from fiber_package.signup.element.types import FormElementUnion, FormTextUnion
|
||||||
|
|
||||||
|
# An activity = communication + slug + endtimes +
|
||||||
|
|
||||||
class ActivityModel(CommunicationModel):
|
class ActivityModel(CommunicationModel):
|
||||||
category: Literal[CommunicationCategory.activity]
|
category: Literal[CommunicationCategory.activity]
|
||||||
|
|
||||||
slug: str
|
slug: str
|
||||||
# unique short name used in the public URL
|
# unique short name used in the public URL
|
||||||
|
|
||||||
start_time: datetime
|
# Every occurance is either a timeframe (start time - end time)
|
||||||
end_time: datetime
|
#
|
||||||
|
occurances: list[Occurrence] = Field(min_length=1)
|
||||||
|
|
||||||
payment_info: ActivityPaymentInfo | None = None
|
payment_info: ActivityPaymentInfo | None = None
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,5 @@ The category is only used to place the communication correctly in the weekly
|
|||||||
mailing and the board-website, it is not visible (or relevant) to readers
|
mailing and the board-website, it is not visible (or relevant) to readers
|
||||||
'''
|
'''
|
||||||
class CommunicationCategory(StrEnum):
|
class CommunicationCategory(StrEnum):
|
||||||
announcement = "announcement"
|
|
||||||
news = "news"
|
news = "news"
|
||||||
activity = "activity"
|
activity = "activity"
|
||||||
|
|||||||
@ -12,3 +12,30 @@ class ActivityPaymentInfo(BaseModel):
|
|||||||
] = None
|
] = None
|
||||||
|
|
||||||
|
|
||||||
|
class TimedOccurrence(BaseModel):
|
||||||
|
kind: Literal["timed"] = "timed"
|
||||||
|
|
||||||
|
start: datetime
|
||||||
|
end: datetime
|
||||||
|
|
||||||
|
@model_validator(mode="after")
|
||||||
|
def validate_interval(self):
|
||||||
|
if self.end <= self.start:
|
||||||
|
raise ValueError("End must be after start")
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
class AllDayOccurrence(BaseModel):
|
||||||
|
kind: Literal["all_day"] = "all_day"
|
||||||
|
|
||||||
|
start_date: date
|
||||||
|
end_date: date # Exclusive!
|
||||||
|
|
||||||
|
@model_validator(mode="after")
|
||||||
|
def validate_interval(self):
|
||||||
|
if self.end_date <= self.start_date:
|
||||||
|
raise ValueError("End date must be after start date")
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
Occurrence = TimedOccurrence | AllDayOccurrence
|
||||||
Loading…
x
Reference in New Issue
Block a user