feat: added seseion for sqlite, alembic and ruff, model Timerr, schemas.py, mixin for id, cruds: create timer, get timer, settings.py for db

This commit is contained in:
Arduinum628
2025-05-08 10:59:28 +03:00
parent 546c8885ac
commit 310f7c2680
19 changed files with 1001 additions and 33 deletions

32
kawai_focus/schemas.py Normal file
View File

@@ -0,0 +1,32 @@
from pydantic import BaseModel, field_validator, Field
from kawai_focus.utils.errors import ErrorMessage
class TimerModel(BaseModel):
"""Модель для валидации данных таймера"""
id: int | None = None
title: str
pomodoro_time: int
break_time: int
break_long_time: int
count_pomodoro: int
class TimerTimeModel(BaseModel):
"""Модель для валидации времени таймера"""
hh: int = Field(0, ge=0, le=23)
mm: int = Field(0, ge=0, le=59)
ss: int = Field(0, ge=0, le=59)
@field_validator('hh', 'mm', 'ss')
@classmethod
def check_all_time_fields(cls, value: int) -> int:
"""Метод валидирует все поля времени"""
# гарантирует, что время не равно 00:00:00
if value == 0:
raise ValueError(ErrorMessage.NO_TIME.value)
return value