on met à jour les événements s'ils ont une date plus récente

This commit is contained in:
Jean-Marie Favreau 2024-02-16 13:51:16 +01:00
parent c5db83cf87
commit 3912da4a7c

View File

@ -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()