From 54222eb8ccced0c218d78a7c7cc6b41de604c714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Wed, 5 Feb 2025 23:38:35 +0100 Subject: [PATCH] Support overwriting details for all events Useful for calendars which contain events of the same kind and the same location only but need some adjustments to improve the usability of the calendar. --- fabcal/calendar_client.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fabcal/calendar_client.py b/fabcal/calendar_client.py index b8d7d63..cde581e 100644 --- a/fabcal/calendar_client.py +++ b/fabcal/calendar_client.py @@ -21,6 +21,9 @@ class ConfiguredCalendar(NamedTuple): name: str url: str default_color: str = None + overwrite_summary: str = None + overwrite_description: str = None + overwrite_location: str = None class CalendarClient: @@ -84,6 +87,11 @@ class CombinedCalendarClient: except KeyError: default_color = None + # if the user wishes to overwrite some data on every item in a calendar, we should do so + overwrite_summary = configured_calendar.overwrite_summary + overwrite_description = configured_calendar.overwrite_description + overwrite_location = configured_calendar.overwrite_location + # we don't copy anything but events from the for event in cal.walk("VEVENT"): # if no color has been configured in the event, we @@ -91,6 +99,15 @@ class CombinedCalendarClient: if "color" not in event: event["color"] = default_color + if overwrite_summary: + event["SUMMARY"] = overwrite_summary + + if overwrite_description: + event["DESCRIPTION"] = overwrite_description + + if overwrite_location: + event["LOCATION"] = overwrite_location + combined_calendar.add_component(event) return combined_calendar