Auth: Require logged in user to delete registrations, team_registrations and subscriptions

This commit is contained in:
2025-10-16 10:54:20 +02:00
parent 1df2ecbebf
commit bfe40a4837
4 changed files with 40 additions and 15 deletions

View File

@@ -33,8 +33,12 @@ class Event(Base):
team_prep_min: Mapped[int] = mapped_column(default=1, nullable=False)
team_prep_max: Mapped[int] = mapped_column(default=1, nullable=False)
registrations: Mapped[list["Registration"]] = relationship("Registration", cascade="all, delete")
team: Mapped[list["TeamRegistration"]] = relationship("TeamRegistration", cascade="all, delete")
registrations: Mapped[list["Registration"]] = relationship(
"Registration", cascade="all, delete"
)
team: Mapped[list["TeamRegistration"]] = relationship(
"TeamRegistration", cascade="all, delete"
)
def team_min_reached(self, work_type: WorkTypes):
threshold = {
@@ -62,6 +66,14 @@ class Event(Base):
self.team_max_reached(work_type) for work_type in typing.get_args(WorkTypes)
)
@property
def registration_open(self):
return datetime.now() < self.registration_deadline
@property
def in_the_past(self):
return datetime.now() > self.event_time
class TeamRegistration(Base):
__tablename__ = "teamregistration"