68 строки
1.2 KiB
Python
68 строки
1.2 KiB
Python
from datetime import datetime
|
|
from enum import Enum
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class UserRole(Enum):
|
|
user = 'user'
|
|
moderator = 'moderator'
|
|
admin = 'admin'
|
|
|
|
|
|
class User(BaseModel):
|
|
id: int
|
|
telegram_user_id: int = Field(
|
|
exclude=True,
|
|
)
|
|
first_name: str
|
|
last_name: Optional[str]
|
|
username: Optional[str]
|
|
role: UserRole
|
|
|
|
|
|
class Scripts(BaseModel):
|
|
id: int
|
|
owner: User
|
|
name: str
|
|
start_time: str
|
|
messages = []
|
|
is_enabled: bool
|
|
|
|
|
|
########################################################################################################################
|
|
|
|
|
|
class PollSchema(BaseModel):
|
|
id: int
|
|
name: str
|
|
question: str
|
|
|
|
|
|
class PollOption(BaseModel):
|
|
id: int
|
|
poll_schema: PollSchema
|
|
name: str
|
|
ordinal: Optional[int]
|
|
|
|
|
|
class Poll(BaseModel):
|
|
id: int
|
|
telegram_message_id: int = Field(
|
|
exclude=True,
|
|
)
|
|
telegram_poll_id: str = Field(
|
|
exclude=True,
|
|
)
|
|
poll_schema: PollSchema
|
|
created_at: datetime
|
|
is_complete: bool
|
|
|
|
|
|
class PollAnswer(BaseModel):
|
|
id: int
|
|
poll: Poll
|
|
user: User
|
|
poll_option: list[PollOption]
|