feat: Gruppen-Sichtbarkeit – genau ein designierter Kalender pro Person
Neues user_settings.group_visible_calendar_id: jedes Mitglied waehlt EINEN lokalen Kalender, der in seinen Gruppen sichtbar ist. Die kombinierte Ansicht ueberlagert nur diesen (statt aller) Kalender je Mitglied + den Gruppenkalender; private Termine weiter gefiltert. Settings GET/PUT erweitert (nullbar). Tests angepasst + ergaenzt (14 gruen). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -313,16 +313,26 @@ def combined_events(
|
||||
b = _strip_busy(b)
|
||||
all_events.append(b)
|
||||
|
||||
# Each member's own local calendars (excluding the group calendar to avoid dupes).
|
||||
# Each member shares exactly one calendar into their groups, chosen in their
|
||||
# settings (group_visible_calendar_id). Only that calendar is overlaid.
|
||||
for m in members:
|
||||
member_cals = (
|
||||
db.query(models.LocalCalendar)
|
||||
.filter(models.LocalCalendar.user_id == m.user_id)
|
||||
.all()
|
||||
settings = (
|
||||
db.query(models.UserSettings)
|
||||
.filter(models.UserSettings.user_id == m.user_id)
|
||||
.first()
|
||||
)
|
||||
for cal in member_cals:
|
||||
if group_cal_id is not None and cal.id == group_cal_id:
|
||||
continue
|
||||
visible_id = settings.group_visible_calendar_id if settings else None
|
||||
if visible_id is None or visible_id == group_cal_id:
|
||||
continue
|
||||
cal = (
|
||||
db.query(models.LocalCalendar)
|
||||
.filter(
|
||||
models.LocalCalendar.id == visible_id,
|
||||
models.LocalCalendar.user_id == m.user_id, # must be the member's own
|
||||
)
|
||||
.first()
|
||||
)
|
||||
if cal:
|
||||
emit_calendar(cal, m.user_id, is_group=False)
|
||||
|
||||
# The group calendar itself.
|
||||
|
||||
@@ -28,6 +28,7 @@ class SettingsUpdate(BaseModel):
|
||||
line_color: Optional[str] = None
|
||||
bg_color: Optional[str] = None
|
||||
private_event_visibility: Optional[str] = None
|
||||
group_visible_calendar_id: Optional[int] = None
|
||||
|
||||
|
||||
def _settings_dict(s: models.UserSettings) -> dict:
|
||||
@@ -48,6 +49,7 @@ def _settings_dict(s: models.UserSettings) -> dict:
|
||||
"line_color": s.line_color,
|
||||
"bg_color": s.bg_color,
|
||||
"private_event_visibility": s.private_event_visibility or "busy",
|
||||
"group_visible_calendar_id": s.group_visible_calendar_id,
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +92,7 @@ def update_settings(
|
||||
# For these three override colours, an explicit null is meaningful
|
||||
# ("reset to default") and must be persisted as NULL. All other fields
|
||||
# keep the previous behaviour where a null/missing value is ignored.
|
||||
NULLABLE_OVERRIDES = {"text_color", "line_color", "bg_color"}
|
||||
NULLABLE_OVERRIDES = {"text_color", "line_color", "bg_color", "group_visible_calendar_id"}
|
||||
update_data = data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
if field in NULLABLE_OVERRIDES:
|
||||
|
||||
Reference in New Issue
Block a user