Add shop
This commit is contained in:
@@ -17,6 +17,13 @@ class GameProposalMode(str, Enum):
|
||||
ORGANIZER_ONLY = "organizer_only"
|
||||
|
||||
|
||||
class CertificationStatus(str, Enum):
|
||||
NONE = "none"
|
||||
PENDING = "pending"
|
||||
CERTIFIED = "certified"
|
||||
REJECTED = "rejected"
|
||||
|
||||
|
||||
class Marathon(Base):
|
||||
__tablename__ = "marathons"
|
||||
|
||||
@@ -35,12 +42,28 @@ class Marathon(Base):
|
||||
cover_url: Mapped[str | None] = mapped_column(String(500), nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
|
||||
# Certification fields
|
||||
certification_status: Mapped[str] = mapped_column(String(20), default=CertificationStatus.NONE.value)
|
||||
certification_requested_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
certified_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
certified_by_id: Mapped[int | None] = mapped_column(ForeignKey("users.id", ondelete="SET NULL"), nullable=True)
|
||||
certification_rejection_reason: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
|
||||
# Shop/Consumables settings
|
||||
allow_skips: Mapped[bool] = mapped_column(Boolean, default=True)
|
||||
max_skips_per_participant: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
||||
allow_consumables: Mapped[bool] = mapped_column(Boolean, default=True)
|
||||
|
||||
# Relationships
|
||||
creator: Mapped["User"] = relationship(
|
||||
"User",
|
||||
back_populates="created_marathons",
|
||||
foreign_keys=[creator_id]
|
||||
)
|
||||
certified_by: Mapped["User | None"] = relationship(
|
||||
"User",
|
||||
foreign_keys=[certified_by_id]
|
||||
)
|
||||
participants: Mapped[list["Participant"]] = relationship(
|
||||
"Participant",
|
||||
back_populates="marathon",
|
||||
@@ -61,3 +84,7 @@ class Marathon(Base):
|
||||
back_populates="marathon",
|
||||
cascade="all, delete-orphan"
|
||||
)
|
||||
|
||||
@property
|
||||
def is_certified(self) -> bool:
|
||||
return self.certification_status == CertificationStatus.CERTIFIED.value
|
||||
|
||||
Reference in New Issue
Block a user