File tree Expand file tree Collapse file tree 5 files changed +157
-0
lines changed Expand file tree Collapse file tree 5 files changed +157
-0
lines changed Original file line number Diff line number Diff line change 1+ from enum import Enum
2+
3+ from pydantic import BaseModel
4+
5+
6+ class InfractionType (str , Enum ):
7+ """An enumeration of codejam infraction types."""
8+
9+ note = "note"
10+ ban = "ban"
11+ warning = "warning"
12+
13+
14+ class Infraction (BaseModel ):
15+ """A model representing an infraction."""
16+
17+ user_id : int
18+ jam_id : int
19+ reason : str
20+ infraction_type : InfractionType
21+
22+
23+ class InfractionResponse (Infraction ):
24+ """Response model representing an infraction."""
25+
26+ id : int
27+
28+ class Config :
29+ """Sets ORM mode to true so that pydantic will validate the objects returned by SQLAlchemy."""
30+
31+ orm_mode = True
Original file line number Diff line number Diff line change 1+ from pydantic import BaseModel
2+
3+ from api .models .schemas .old import infraction , team , winner
4+
5+
6+ class CodeJam (BaseModel ):
7+ """A model representing a codejam."""
8+
9+ name : str
10+ teams : list [team .Team ]
11+ ongoing : bool = False
12+
13+
14+ class CodeJamResponse (CodeJam ):
15+ """Response model representing a code jam."""
16+
17+ id : int
18+ teams : list [team .TeamResponse ]
19+ infractions : list [infraction .InfractionResponse ]
20+ winners : list [winner .Winner ]
21+
22+ class Config :
23+ """Sets ORM mode to true so that pydantic will validate the objects returned by SQLAlchemy."""
24+
25+ orm_mode = True
Original file line number Diff line number Diff line change 1+ from typing import Optional
2+
3+ from pydantic import BaseModel
4+
5+ from api .models .schemas .old import user
6+
7+
8+ class Team (BaseModel ):
9+ """A model representing a team for a codejam."""
10+
11+ name : str
12+ users : list [user .User ]
13+ discord_role_id : Optional [int ] = None
14+ discord_channel_id : Optional [int ] = None
15+
16+
17+ class TeamResponse (Team ):
18+ """Response model representing a team."""
19+
20+ id : int
21+ jam_id : int
22+
23+ class Config :
24+ """Sets ORM mode to true so that pydantic will validate the objects returned by SQLAlchemy."""
25+
26+ orm_mode = True
27+
28+
29+ class UserTeamResponse (BaseModel ):
30+ """Response model representing user and team relationship."""
31+
32+ user_id : int
33+ team : TeamResponse
34+ is_leader : bool
35+
36+ class Config :
37+ """Sets ORM mode to true so that pydantic will validate the objects returned by SQLAlchemy."""
38+
39+ orm_mode = True
Original file line number Diff line number Diff line change 1+ from pydantic import BaseModel
2+
3+ from api .models .schemas .old import infraction
4+
5+
6+ class User (BaseModel ):
7+ """A model representing a user for a codejam."""
8+
9+ user_id : int
10+ is_leader : bool
11+
12+ class Config :
13+ """Sets ORM mode to true so that pydantic will validate the objects returned by SQLAlchemy."""
14+
15+ orm_mode = True
16+
17+
18+ class ParticipationHistory (BaseModel ):
19+ """A model representing the participation history of a user in a codejam."""
20+
21+ jam_id : int
22+ top_10 : bool
23+ first_place : bool
24+ team_id : int
25+ is_leader : bool
26+ infractions : list [infraction .InfractionResponse ]
27+
28+ class Config :
29+ """Sets ORM mode to true so that pydantic will validate the objects returned by SQLAlchemy."""
30+
31+ orm_mode = True
32+
33+
34+ class UserResponse (BaseModel ):
35+ """Response model representing a user."""
36+
37+ id : int
38+ participation_history : list [ParticipationHistory ]
39+
40+ class Config :
41+ """Sets ORM mode to true so that pydantic will validate the objects returned by SQLAlchemy."""
42+
43+ orm_mode = True
Original file line number Diff line number Diff line change 1+ from pydantic import BaseModel
2+
3+
4+ class Winner (BaseModel ):
5+ """A model representing a codejam winner."""
6+
7+ user_id : int
8+ first_place : bool
9+
10+ class Config :
11+ """Sets ORM mode to true so that pydantic will validate the objects returned by SQLAlchemy."""
12+
13+ orm_mode = True
14+
15+
16+ class WinnerResponse (Winner ):
17+ """Response model representing a codejam winner."""
18+
19+ jam_id : int
You can’t perform that action at this time.
0 commit comments