From d0195612f0e7e165a4f036f10aee55918dfaab6e Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Mon, 11 Nov 2024 16:51:42 +0100 Subject: [PATCH] =?UTF-8?q?On=20ne=20met=20=C3=A0=20jour=20les=20tags,=20e?= =?UTF-8?q?tc.=20que=20si=20c'est=20une=20version=20import=20pur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/agenda_culturel/models.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index 0cab685..770e073 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -1184,10 +1184,10 @@ class Event(models.Model): events.sort(key=lambda e: e.imported_date, reverse=True) return events[0] - def update(self, other): + def update(self, other, all): # set attributes - for attr in Event.data_fields(): + for attr in Event.data_fields(all=all): setattr(self, attr, getattr(other, attr)) # adjust modified date if required @@ -1236,12 +1236,13 @@ class Event(models.Model): if len(same_events) != 0: # check if one event has been imported and not modified in this list same_imported = Event.find_last_pure_import(same_events) - + pure = True # if not, we check if it does not match exactly with another if not same_imported: for e in same_events: if event.similar(e, False): same_imported = e + pure = False break if same_imported: @@ -1253,7 +1254,7 @@ class Event(models.Model): same_imported.other_versions.representative = None same_imported.other_versions.save() - same_imported.update(event) + same_imported.update(event, pure) # we only update all tags if it"s a pure import same_imported.set_in_importation_process() same_imported.prepare_save() to_update.append(same_imported)