Files
duty-teller/db/schemas.py
Nikolay Tatarinov bf9fc59a3f Implement external calendar integration and enhance API functionality
- Added support for fetching and parsing external ICS calendars, allowing events to be displayed on the duty grid.
- Introduced a new API endpoint `/api/calendar-events` to retrieve calendar events within a specified date range.
- Updated configuration to include `EXTERNAL_CALENDAR_ICS_URL` for specifying the ICS calendar URL.
- Enhanced the web application to visually indicate days with events and provide event summaries on hover.
- Improved documentation in the README to include details about the new calendar integration and configuration options.
- Updated tests to cover the new calendar functionality and ensure proper integration.
2026-02-17 20:58:59 +03:00

53 lines
977 B
Python

"""Pydantic schemas for API and validation."""
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 for calendar display."""
full_name: str
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