Archived
Add models
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from uuid import uuid4
|
||||
from datetime import datetime
|
||||
|
||||
class ContestBase(BaseModel):
|
||||
id: uuid4 = Field(default_factory=uuid4, description="Contest ID. Required.", examples=["3a4c5f1d-3a4c-4f1d-3a4c-5f1d3a4c5f1d"])
|
||||
city_name: str = Field(..., description="Name of the city where the contest is held. Required.", examples=["Helsinki"])
|
||||
date: datetime = Field(..., description="Date when the contest is to be held. Required.", examples=["2024-10-20"])
|
||||
round: int = Field(..., description="Can be one of '1st semifinal' = 1, '2nd semifinal' = 2, 'final' = 3. Required.", examples=["1"])
|
||||
is_active: bool = Field(default=False, description="Is the contest active? Default is False.", examples=["False"])
|
||||
|
||||
class ContestCreate(ContestBase):
|
||||
pass
|
||||
|
||||
class ContestUpdate(ContestBase):
|
||||
pass
|
||||
|
||||
class ContestOut(ContestBase):
|
||||
pass
|
||||
@@ -0,0 +1,20 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
|
||||
class SongBase(BaseModel):
|
||||
id: uuid4 = Field(default_factory=uuid4, description="Song ID. Required.", examples=["3a4c5f1d-3a4c-4f1d-3a4c-5f1d3a4c5f1d"])
|
||||
|
||||
class SongIn(SongBase):
|
||||
artist: str = Field(..., description="Artist of the song. Required.", examples=["Matti Meikäläinen"])
|
||||
song_name: str = Field(..., description="Name of the song. Required.", examples=["Moi"])
|
||||
country: str = Field(..., description="Country where the song is from. Required.", examples=["Finland"])
|
||||
|
||||
class SongReview(SongBase):
|
||||
contest_id: UUID = Field(..., description="Contest ID. Required.", examples=["3a4c5f1d-3a4c-4f1d-3a4c-5f1d3a4c5f1d"])
|
||||
song_id: UUID = Field(..., description="Song ID. Required.", examples=["3a4c5f1d-3a4c-4f1d-3a4c-5f1d3a4c5f1d"])
|
||||
reviewer_id: UUID = Field(..., description="Reviewer ID. Required.", examples=["3a4c5f1d-3a4c-4f1d-3a4c-5f1d3a4c5f1d"])
|
||||
song_score: int = Field(..., description="Song score. Required.", examples=[50])
|
||||
wardrobe_score: int = Field(..., description="Wardrobe score. Required.", examples=[50])
|
||||
stage_show_score: int = Field(..., description="Stage show score. Required.", examples=[50])
|
||||
review_text: str | None = Field(None, description="Review text. Optional.", examples=["Great song!"])
|
||||
@@ -0,0 +1,22 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from uuid import uuid4
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class UserBase(BaseModel):
|
||||
username: str = Field(..., description="Username. Required.", examples=["mmeikala"])
|
||||
|
||||
class UserIn(UserBase):
|
||||
password: str = Field(..., description="Hashed password. Required.", examples=["p455w0rd"])
|
||||
|
||||
class UserCreate(UserBase):
|
||||
id: uuid4 = Field(default_factory=uuid4, description="User ID. Required.", examples=["3a4c5f1d-3a4c-4f1d-3a4c-5f1d3a4c5f1d"])
|
||||
name: str | None = Field(None, description="Real name of the user. Optional.", examples=["Matti Meikäläinen"])
|
||||
email: str | None = Field(None, description="Email address of the user. Optional.", examples=["[email protected]"])
|
||||
group_id: uuid4 = Field(..., description="Group ID. Required.", examples=["3a4c5f1d-3a4c-4f1d-3a4c-5f1d3a4c5f1d"])
|
||||
|
||||
class UserOut(UserCreate):
|
||||
last_login: datetime | None = Field(None, description="Last login time. Is null by default. Updated automatically.", examples=["2024-10-20 12:00:00"])
|
||||
created_at: datetime = Field(default_factory=datetime.now, description="Creation time. Defaults to current time.", examples=["2024-10-20 12:00:00"])
|
||||
modified_at: datetime = Field(default_factory=datetime.now, description="Modification time. Defaults to current time.", examples=["2024-10-20 12:00:00"])
|
||||
|
||||
Reference in New Issue
Block a user