-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinfraction.py
More file actions
23 lines (16 loc) · 782 Bytes
/
infraction.py
File metadata and controls
23 lines (16 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from typing import Literal
from sqlalchemy import Enum, ForeignKey, String
from sqlalchemy.orm import Mapped, mapped_column
from api.models.orm.base import Base
InfractionType = Literal["note", "ban", "warning"]
class Infraction(Base):
"""An infraction that was applied to a user."""
__tablename__ = "infractions"
infraction_id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
user_id: Mapped[int] = mapped_column(ForeignKey("users.user_id"))
issued_in_jam_id: Mapped[int] = mapped_column(ForeignKey("jams.jam_id"))
infraction_type: Mapped[InfractionType] = mapped_column(
Enum(*InfractionType.__args__, name="infraction_type"),
nullable=False,
)
reason: Mapped[str] = mapped_column(String(), nullable=False)