From 7700478f1be17f4a4c196aa5fc2f873bec6a5bb1 Mon Sep 17 00:00:00 2001 From: "Evgeny (Krymmy) Momotov" Date: Wed, 12 Nov 2025 16:35:26 +0300 Subject: [PATCH] [UP] data_models.py --- src/CallerApiManager/data_models.py | 52 ++++++++--------------------- 1 file changed, 14 insertions(+), 38 deletions(-) diff --git a/src/CallerApiManager/data_models.py b/src/CallerApiManager/data_models.py index 0c06dce..d9873db 100644 --- a/src/CallerApiManager/data_models.py +++ b/src/CallerApiManager/data_models.py @@ -29,41 +29,17 @@ class User(BaseModel): id: Optional[int] = Field(description="Идентификатор (автоматический)", default=None) username: str = Field(max_length=150, description="Пользовательское имя", example="john_doe") #password: str = Field(max_length=255, description="Пароль", example="secret123") - email: str = Field(max_length=254, default="", description="Электронная почта", example="john@example.com") - first_name: str = Field(max_length=150, default="", description="Имя", example="John") - last_name: str = Field(max_length=150, default="", description="Фамилия", example="Doe") + email: Optional[str] = Field(max_length=254, default="", description="Электронная почта", example="john@example.com") + first_name: Optional[str] = Field(max_length=150, default="", description="Имя", example="John") + last_name: Optional[str] = Field(max_length=150, default="", description="Фамилия", example="Doe") #is_staff: bool = Field(default=False, description="Статус администратора") #is_active: bool = Field(default=False, description="Активен") #is_superuser: bool = Field(default=False, description="Суперпользователь") #date_joined: str = Field(description="Дата создания", example="2024-01-01T12:00:00") #last_login: Optional[str] = Field(null=True, default=None, description="Последний вход") - @validator("email") - def validate_email(cls, v): - if v and "@" not in v or "." not in v: - raise ValueError("Некорректный email") - return v - - @validator("username") - def validate_username(cls, v): - if len(v) > 150: - raise ValueError("Имя пользователя слишком длинное (максимум 150 символов)") - return v - - @validator("first_name") - def validate_first_name(cls, v): - if v and len(v) > 150: - raise ValueError("Имя слишком длинное (максимум 150 символов)") - return v - - @validator("last_name") - def validate_last_name(cls, v): - if v and len(v) > 150: - raise ValueError("Фамилия слишком длинная (максимум 150 символов)") - return v - class Config: - extra = "forbid" + extra = "ignore" from_attributes = True @@ -141,7 +117,7 @@ class SIPAccount(BaseModel): return v class Config: - extra = "forbid" + extra = "ignore" from_attributes = True class CallPrompt(BaseModel): @@ -155,7 +131,7 @@ class CallPrompt(BaseModel): updated_at: Optional[str] = Field(description="Дата обновления", example="2024-01-01T12:00:00") class Config: - extra = "forbid" + extra = "ignore" from_attributes = True @@ -192,7 +168,7 @@ class YandexFleet(BaseModel): updated_at: Optional[str] = Field(description="Дата обновления", example="2024-01-01T12:00:00") class Config: - extra = "forbid" + extra = "ignore" from_attributes = True @@ -204,7 +180,7 @@ class Driver(BaseModel): updated_at: Optional[str] = Field(description="Дата обновления", example="2024-01-01T12:00:00") class Config: - extra = "forbid" + extra = "ignore" from_attributes = True @@ -223,7 +199,7 @@ class Call(BaseModel): updated_at: Optional[str] = Field(description="Дата обновления", example="2024-01-01T12:00:00") class Config: - extra = "forbid" + extra = "ignore" from_attributes = True @@ -239,7 +215,7 @@ class CallIn(BaseModel): audio_file: Optional[str] = Field(description="Путь к аудио", example="/audio/call-123.mp3", null=True) class Config: - extra = "forbid" + extra = "ignore" from_attributes = True @@ -254,7 +230,7 @@ class CallDialog(BaseModel): updated_at: Optional[str] = Field(description="Дата обновления", example="2024-01-01T12:00:00") class Config: - extra = "forbid" + extra = "ignore" from_attributes = True class CallDialogIn(BaseModel): @@ -265,7 +241,7 @@ class CallDialogIn(BaseModel): call_time: Optional[int] = Field(default=0, description="Время звонка (в секундах)", ge=0) class Config: - extra = "forbid" + extra = "ignore" from_attributes = True @@ -276,7 +252,7 @@ class CallDialogPart(BaseModel): call_time: int = Field(default=0, description="Время звонка (в секундах)", ge=0) class Config: - extra = "forbid" + extra = "ignore" from_attributes = True class CallDialogPartIn(BaseModel): @@ -286,5 +262,5 @@ class CallDialogPartIn(BaseModel): call_time: Optional[int] = Field(default=0, description="Время звонка (в секундах)", ge=0) class Config: - extra = "forbid" + extra = "ignore" from_attributes = True \ No newline at end of file