ungana

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README

commit 7169599ee84dbc2ebad52eedc8c222f3ba8f5488
parent f67b2e8fe0d05bb8ca23033e2a82d2264fa8fe7c
Author: Carlosokumu <carlosokumu254@gmail.com>
Date:   Thu, 21 Aug 2025 22:39:55 +0300

update IcalManager update_event  method to ensure that If you run edit multiple times with the same poster or long attachment, it won’t duplicate the fields

Diffstat:
Mcalendarapp/ical/ical_manager.py | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)

diff --git a/calendarapp/ical/ical_manager.py b/calendarapp/ical/ical_manager.py @@ -56,6 +56,26 @@ class ICalManager: else: component[key] = value if attachments: + existing = component.get("ATTACH") + if not existing: + existing = [] + elif not isinstance(existing, list): + existing = [existing] + + preserved = [] + for e in existing: + ctx = None + if hasattr(e, "params"): + ctx = e.params.get("CTX") + if ctx not in ("poster", "long"): + preserved.append(e) + + if "ATTACH" in component: + component.pop("ATTACH") + + for e in preserved: + component.add("ATTACH", e) + for attachment in attachments: if isinstance(attachment, tuple) and len(attachment) == 3: prop, value, params = attachment