From 4752e9d555d76da108bebf4e65e3a2ab0247bf30 Mon Sep 17 00:00:00 2001 From: Marc Koch Date: Tue, 19 Aug 2025 13:00:01 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20move=20recurring=20event?= =?UTF-8?q?=20canellation=20into=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/clear_bookings.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/clear_bookings.py b/src/clear_bookings.py index 9019f36..6422838 100644 --- a/src/clear_bookings.py +++ b/src/clear_bookings.py @@ -158,6 +158,14 @@ class DavEvent: self.is_deleted = True self.obj.delete() + def cancel(self): + """ + Cancel the event. + :return: + """ + self.obj.icalendar_component["status"] = "CANCELLED" + self.obj.save(no_create=True) + def serialize(self) -> dict[str, str | datetime | timedelta]: """ Serialize the event to a dictionary. @@ -314,8 +322,7 @@ def clear(target_calendars: list, is_test: bool=False) -> dict: # we need to cancel it now elif not event.is_cancelled: if not is_test: - event.obj.icalendar_component["status"] = "CANCELLED" - event.obj.save() + event.cancel() is_cancelled = True result["cancellation_type"] = "cancelled" results["cancelled_overlapping_recurring_events"].append(result)