From 3912da4a7ce1a57aa44b592b20c8bc4e2115c3de Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Fri, 16 Feb 2024 13:51:16 +0100 Subject: [PATCH] =?UTF-8?q?on=20met=20=C3=A0=20jour=20les=20=C3=A9v=C3=A9n?= =?UTF-8?q?ements=20s'ils=20ont=20une=20date=20plus=20r=C3=A9cente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/agenda_culturel/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index 287a8f6..ccba7e4 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -550,6 +550,10 @@ class Event(models.Model): for attr in Event.data_fields(): setattr(self, attr, getattr(other, attr)) + # adjust modified date if required + if other.modified_date and self.modified_date < other.modified_date: + self.modified_date = other.modified_date + # set status according to the input status if other.status is not None: self.status = other.status @@ -597,7 +601,7 @@ class Event(models.Model): if same_imported: # if this event exists, it will be updated with new data only if the data is fresher - if same_imported.modified_date < event.modified_date or event.status != same_imported.status: + if same_imported.modified_date < event.modified_date: same_imported.update(event) same_imported.set_in_importation_process() same_imported.prepare_save()