From 3df89e6a529c2ee1b6b2984534138b74a8627466 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Fri, 24 Jan 2025 13:53:52 +0100 Subject: [PATCH] Fix #286 (again) --- src/agenda_culturel/models.py | 14 +++++++++++++- src/agenda_culturel/static/js/modal.js | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index f887fac..8e9fa0c 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -1613,7 +1613,7 @@ class Event(models.Model): # Limitation: the given events should not be considered similar one to another... def import_events(events, remove_missing_from_source=None, user_id=None): - + logger.warning("aaaaaa >>>f") user = None if user_id: user = User.objects.filter(pk=user_id).first() @@ -1627,6 +1627,7 @@ class Event(models.Model): # for each event, check if it's a new one, or a one to be updated for event in events: + logger.warning("aaaa1 >>>f") sdate = date.fromisoformat(event.start_day) if event.end_day: edate = date.fromisoformat(event.end_day) @@ -1641,15 +1642,19 @@ class Event(models.Model): if event.uuids and len(event.uuids) > 0: uuids |= set(event.uuids) + logger.warning("aaaa2 >>>f") + # imported events should be updated event.set_in_importation_process() event.set_processing_user(user) event.prepare_save() + logger.warning("aaaa3 >>>f") # check if the event has already be imported (using uuid) same_events = event.find_same_events_by_uuid() if len(same_events) != 0: + logger.warning("aaaa4 >>>f") # check if one event has been imported and not modified in this list same_imported = Event.find_last_pure_import(same_events) pure = True @@ -1661,7 +1666,9 @@ class Event(models.Model): pure = False break + logger.warning("aaaa5 >>>f") if same_imported: + logger.warning("aaaa6 >>>f") # reopen DuplicatedEvents if required if not event.similar(same_imported, False) and same_imported.other_versions: if same_imported.status != Event.STATUS.TRASH: @@ -1680,6 +1687,7 @@ class Event(models.Model): same_imported.save(update_fields=["local_image"]) to_update.append(same_imported) else: + logger.warning("aaaa7 >>>f") # otherwise, the new event possibly a duplication of the remaining others. # check if it should be published @@ -1702,6 +1710,7 @@ class Event(models.Model): # import this new event to_import.append(event) + logger.warning("aaaa666 >>>f") for e in to_import: if e.is_event_long_duration(): e.status = Event.STATUS.DRAFT @@ -1722,12 +1731,14 @@ class Event(models.Model): msg = ti.get_message() msg.related_event = i msg.save() + logger.warning("bbbbbb >>>f") nb_updated = Event.objects.bulk_update( to_update, fields=Event.data_fields(no_m2m=True) + ["imported_date", "modified_date", "uuids", "status", "import_sources"], ) + logger.warning("ccccccc >>>f") nb_draft = 0 if remove_missing_from_source is not None and max_date is not None: @@ -1761,6 +1772,7 @@ class Event(models.Model): to_draft.append(e) nb_draft = Event.objects.bulk_update(to_draft, fields=["status"]) + logger.warning("dddddd >>>f") return imported, nb_updated, nb_draft diff --git a/src/agenda_culturel/static/js/modal.js b/src/agenda_culturel/static/js/modal.js index dede440..7b20e02 100644 --- a/src/agenda_culturel/static/js/modal.js +++ b/src/agenda_culturel/static/js/modal.js @@ -36,7 +36,7 @@ const openModal = (modal, back=true) => { visibleModal = modal; const mask = visibleModal.querySelector(".h-mask"); - if (mask) + if (mask != null) mask.classList.add("visible"); }, 350); }; @@ -44,7 +44,7 @@ const openModal = (modal, back=true) => { const hideModal = (modal) => { if (modal != null) { const mask = visibleModal.querySelector(".h-mask"); - if (mask) + if (mask != null) mask.classList.remove("visible"); visibleModal = null; document.documentElement.style.removeProperty("--scrollbar-width");