From 57344ff5b96d62f7ec16b9ec0a5e12dcbf8a7c71 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sat, 2 Nov 2024 19:24:26 +0100 Subject: [PATCH] =?UTF-8?q?On=20ignore=20les=20tags=20et=20cat=C3=A9gories?= =?UTF-8?q?=20quand=20on=20cherche=20les=20similarit=C3=A9s=20au=20moment?= =?UTF-8?q?=20des=20imports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/agenda_culturel/models.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index dce5282..14b09e4 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -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)