37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
from typing import Literal, Self
|
|
from pydantic import model_validator
|
|
|
|
from datetime import datetime
|
|
|
|
from .communication import CommunicationModel
|
|
from .submodels import ActivityPaymentInfo
|
|
from .enums import CommunicationCategory
|
|
|
|
from fiber_package.refs import SignupRefList
|
|
|
|
from fiber_package.signup.elements.form_element import FormElement
|
|
|
|
class ActivityModel(CommunicationModel):
|
|
category: Literal[CommunicationCategory.activity]
|
|
|
|
slug: str
|
|
# unique short name used in the public URL
|
|
|
|
start_time: datetime
|
|
end_time: datetime
|
|
|
|
payment_info: ActivityPaymentInfo | None = None
|
|
|
|
form: list[FormElement]
|
|
|
|
signups: SignupRefList = SignupRefList([], "signup")
|
|
|
|
# TODO: see Felt 'activiteiten' DB schema. Things like:
|
|
# email, target group, maximal attendees ....
|
|
|
|
@model_validator(mode='after')
|
|
def check_end_after_start(self) -> Self:
|
|
if self.end_time < self.start_time:
|
|
raise ValueError("End time cannot be earlier than start time")
|
|
return self
|