Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Extract events/calendar functionality into standalone microservice: - app.py and events_api.py from apps/events/ - Calendar blueprints (calendars, calendar, calendar_entries, calendar_entry, day, slots, slot, ticket_types, ticket_type) - Templates for all calendar/event views including admin - Dockerfile (APP_MODULE=app:app, IMAGE=events) - entrypoint.sh (no Alembic - migrations managed by blog app) - Gitea CI workflow for build and deploy Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
|
|
from models.calendars import Calendar
|
|
from ...calendars.services.calendars import CalendarError
|
|
|
|
async def update_calendar_config(sess, calendar_id: int, *, description: str | None, slots: list | None):
|
|
"""Update description and slots for a calendar."""
|
|
cal = await sess.get(Calendar, calendar_id)
|
|
if not cal:
|
|
raise CalendarError(f"Calendar {calendar_id} not found.")
|
|
cal.description = (description or '').strip() or None
|
|
# Validate slots shape a bit
|
|
norm_slots: list[dict] = []
|
|
if slots:
|
|
for s in slots:
|
|
if not isinstance(s, dict):
|
|
continue
|
|
norm_slots.append({
|
|
"days": str(s.get("days", ""))[:7].lower(),
|
|
"time_from": str(s.get("time_from", ""))[:5],
|
|
"time_to": str(s.get("time_to", ""))[:5],
|
|
"cost_name": (s.get("cost_name") or "")[:64],
|
|
"description": (s.get("description") or "")[:255],
|
|
})
|
|
cal.slots = norm_slots or None
|
|
await sess.flush()
|
|
return cal
|