feat(calendar): Live-Refresh ueber CalDAV, Tagklick-Navigation, Listen-Ansicht
- caldav.py sendet SSE-Notifications bei Event-PUT/DELETE und Kalender-Loeschung, damit das Web-UI auch auf Aenderungen aus DAVx5 sofort reagiert. - FullCalendar navLinks: Klick auf Tagesnummer im Monatsraster wechselt in die Tagesansicht. - Neue Listen-Ansicht mit Volltext-Suche, Datumsbereich, Kalender-Filter, Sortierung nach Datum/Titel und Loeschen-Button pro Zeile. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -26,8 +26,14 @@ from functools import wraps
|
||||
from flask import Response, request
|
||||
|
||||
from app.extensions import db
|
||||
from app.models.calendar import Calendar, CalendarEvent
|
||||
from app.models.calendar import Calendar, CalendarEvent, CalendarShare
|
||||
from app.models.user import User
|
||||
from app.services.events import notify_calendar_change
|
||||
|
||||
|
||||
def _cal_recipients(cal: 'Calendar'):
|
||||
return [s.shared_with_id for s in
|
||||
CalendarShare.query.filter_by(calendar_id=cal.id).all()]
|
||||
|
||||
from . import dav_bp
|
||||
|
||||
@@ -513,6 +519,8 @@ def put_event(username, cal_part, filename):
|
||||
existing.ical_data = _extract_vevent_block(raw)
|
||||
existing.updated_at = datetime.now(timezone.utc)
|
||||
db.session.commit()
|
||||
notify_calendar_change(cal.owner_id, cal.id, 'event',
|
||||
shared_with=_cal_recipients(cal))
|
||||
|
||||
status = 201 if request.method == 'PUT' and not if_match else 204
|
||||
return Response('', status, {'ETag': _etag_for_event(existing)})
|
||||
@@ -541,6 +549,8 @@ def delete_event(username, cal_part, filename):
|
||||
return Response('', 404)
|
||||
db.session.delete(ev)
|
||||
db.session.commit()
|
||||
notify_calendar_change(cal.owner_id, cal.id, 'event',
|
||||
shared_with=_cal_recipients(cal))
|
||||
return Response('', 204)
|
||||
|
||||
|
||||
@@ -558,8 +568,12 @@ def delete_calendar(username, cal_part):
|
||||
cal = _calendar_for(user, cal_id) if cal_id else None
|
||||
if not cal:
|
||||
return Response('', 404)
|
||||
recipients = _cal_recipients(cal)
|
||||
owner_id = cal.owner_id
|
||||
cid = cal.id
|
||||
db.session.delete(cal)
|
||||
db.session.commit()
|
||||
notify_calendar_change(owner_id, cid, 'deleted', shared_with=recipients)
|
||||
return Response('', 204)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user