Add 3 roles, settings for marathons
This commit is contained in:
@@ -16,6 +16,7 @@ from app.schemas.marathon import (
|
||||
ParticipantWithUser,
|
||||
JoinMarathon,
|
||||
LeaderboardEntry,
|
||||
SetParticipantRole,
|
||||
)
|
||||
from app.schemas.game import (
|
||||
GameCreate,
|
||||
@@ -68,6 +69,7 @@ __all__ = [
|
||||
"ParticipantWithUser",
|
||||
"JoinMarathon",
|
||||
"LeaderboardEntry",
|
||||
"SetParticipantRole",
|
||||
# Game
|
||||
"GameCreate",
|
||||
"GameUpdate",
|
||||
|
||||
@@ -32,7 +32,9 @@ class GameShort(BaseModel):
|
||||
class GameResponse(GameBase):
|
||||
id: int
|
||||
cover_url: str | None = None
|
||||
added_by: UserPublic | None = None
|
||||
status: str = "pending"
|
||||
proposed_by: UserPublic | None = None
|
||||
approved_by: UserPublic | None = None
|
||||
challenges_count: int = 0
|
||||
created_at: datetime
|
||||
|
||||
|
||||
@@ -12,16 +12,21 @@ class MarathonBase(BaseModel):
|
||||
class MarathonCreate(MarathonBase):
|
||||
start_date: datetime
|
||||
duration_days: int = Field(default=30, ge=1, le=365)
|
||||
is_public: bool = False
|
||||
game_proposal_mode: str = Field(default="all_participants", pattern="^(all_participants|organizer_only)$")
|
||||
|
||||
|
||||
class MarathonUpdate(BaseModel):
|
||||
title: str | None = Field(None, min_length=1, max_length=100)
|
||||
description: str | None = None
|
||||
start_date: datetime | None = None
|
||||
is_public: bool | None = None
|
||||
game_proposal_mode: str | None = Field(None, pattern="^(all_participants|organizer_only)$")
|
||||
|
||||
|
||||
class ParticipantInfo(BaseModel):
|
||||
id: int
|
||||
role: str = "participant"
|
||||
total_points: int
|
||||
current_streak: int
|
||||
drop_count: int
|
||||
@@ -37,9 +42,11 @@ class ParticipantWithUser(ParticipantInfo):
|
||||
|
||||
class MarathonResponse(MarathonBase):
|
||||
id: int
|
||||
organizer: UserPublic
|
||||
creator: UserPublic
|
||||
status: str
|
||||
invite_code: str
|
||||
is_public: bool
|
||||
game_proposal_mode: str
|
||||
start_date: datetime | None
|
||||
end_date: datetime | None
|
||||
participants_count: int
|
||||
@@ -51,10 +58,15 @@ class MarathonResponse(MarathonBase):
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class SetParticipantRole(BaseModel):
|
||||
role: str = Field(..., pattern="^(participant|organizer)$")
|
||||
|
||||
|
||||
class MarathonListItem(BaseModel):
|
||||
id: int
|
||||
title: str
|
||||
status: str
|
||||
is_public: bool
|
||||
participants_count: int
|
||||
start_date: datetime | None
|
||||
end_date: datetime | None
|
||||
|
||||
@@ -32,6 +32,7 @@ class UserPublic(UserBase):
|
||||
id: int
|
||||
login: str
|
||||
avatar_url: str | None = None
|
||||
role: str = "user"
|
||||
created_at: datetime
|
||||
|
||||
class Config:
|
||||
|
||||
Reference in New Issue
Block a user