On ignore les tags et catégories quand on cherche les similarités au moment

des imports
This commit is contained in:
Jean-Marie Favreau 2024-11-02 19:24:26 +01:00
parent 2d9a3d42d2
commit 57344ff5b9

View File

@ -1003,9 +1003,9 @@ class Event(models.Model):
possibly_duplicated=self.possibly_duplicated
).exclude(pk=self.pk)
def get_comparison(events):
def get_comparison(events, all=True):
result = []
for attr in Event.data_fields(all=True, local_img=False, exact_location=False):
for attr in Event.data_fields(all=all, local_img=False, exact_location=False):
values = [getattr(e, attr) for e in events]
values = ["" if v is None else v for v in values]
values = [[] if attr == "tags" and v == "" else v for v in values]
@ -1019,8 +1019,8 @@ class Event(models.Model):
result.append({"similar": False, "key": attr, "values": values})
return result
def similar(self, event):
res = Event.get_comparison([self, event])
def similar(self, event, all=True):
res = Event.get_comparison([self, event], all)
for r in res:
if not r["similar"]:
return False
@ -1170,10 +1170,12 @@ 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_imported_not_modified(same_events)
# check if the imported events are similar or not (considering data and not category or tags)
same_events_not_similar = [
e for e in same_events if not e.similar(event)
e for e in same_events if not e.similar(event, False)
]
if same_imported or len(same_events_not_similar) == 0:
# TODO: revoir ici:
if not same_imported:
same_imported = Event.find_last_imported(same_events)