♻️ move recurring event canellation into method

This commit is contained in:
Marc Koch 2025-08-19 13:00:01 +02:00
parent 1d62cab68d
commit 4752e9d555
Signed by: marc
GPG Key ID: 12406554CFB028B9
1 changed files with 9 additions and 2 deletions

View File

@ -158,6 +158,14 @@ class DavEvent:
self.is_deleted = True self.is_deleted = True
self.obj.delete() 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]: def serialize(self) -> dict[str, str | datetime | timedelta]:
""" """
Serialize the event to a dictionary. 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 # we need to cancel it now
elif not event.is_cancelled: elif not event.is_cancelled:
if not is_test: if not is_test:
event.obj.icalendar_component["status"] = "CANCELLED" event.cancel()
event.obj.save()
is_cancelled = True is_cancelled = True
result["cancellation_type"] = "cancelled" result["cancellation_type"] = "cancelled"
results["cancelled_overlapping_recurring_events"].append(result) results["cancelled_overlapping_recurring_events"].append(result)