- Updated `.dockerignore` to exclude test and development artifacts, optimizing the Docker image size. - Refactored `main.py` to delegate execution to `duty_teller.run.main()`, simplifying the entry point. - Introduced a new `duty_teller` package to encapsulate core functionality, improving modularity and organization. - Enhanced `pyproject.toml` to define a script for running the application, streamlining the execution process. - Updated README documentation to reflect changes in project structure and usage instructions. - Improved Alembic environment configuration to utilize the new package structure for database migrations.
59 lines
1.2 KiB
Python
59 lines
1.2 KiB
Python
"""Pydantic schemas for API and validation."""
|
|
|
|
from typing import Literal
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
|
|
class UserBase(BaseModel):
|
|
full_name: str
|
|
username: str | None = None
|
|
first_name: str | None = None
|
|
last_name: str | None = None
|
|
|
|
|
|
class UserCreate(UserBase):
|
|
telegram_user_id: int
|
|
|
|
|
|
class UserInDb(UserBase):
|
|
id: int
|
|
telegram_user_id: int
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class DutyBase(BaseModel):
|
|
user_id: int
|
|
start_at: str # UTC, ISO 8601 with Z
|
|
end_at: str # UTC, ISO 8601 with Z
|
|
|
|
|
|
class DutyCreate(DutyBase):
|
|
pass
|
|
|
|
|
|
class DutyInDb(DutyBase):
|
|
id: int
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class DutyWithUser(DutyInDb):
|
|
"""Duty with full_name and event_type for calendar display.
|
|
|
|
event_type: only these values are returned; unknown DB values are mapped to "duty" in the API.
|
|
"""
|
|
|
|
full_name: str
|
|
event_type: Literal["duty", "unavailable", "vacation"] = "duty"
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class CalendarEvent(BaseModel):
|
|
"""External calendar event (e.g. holiday) for a single day."""
|
|
|
|
date: str # YYYY-MM-DD
|
|
summary: str
|