diff --git a/src/agenda_culturel/forms.py b/src/agenda_culturel/forms.py index 1159027..62d70d5 100644 --- a/src/agenda_culturel/forms.py +++ b/src/agenda_culturel/forms.py @@ -162,13 +162,13 @@ class FixDuplicates(Form): choices += [ ( "SelectA", - "Ces événements sont identiques, on garde A et on masque B", + "Ces événements sont identiques, on conserve A et on masque B", ) ] choices += [ ( "SelectB", - "Ces événements sont identiques, on garde B et on masque A", + "Ces événements sont identiques, on conserve B et on masque A", ) ] choices += [ @@ -189,7 +189,7 @@ class FixDuplicates(Form): choices += [ ( "Select" + i, - "Ces événements sont identiques, on garde " + "Ces événements sont identiques, on conserve " + i + " et on masque les autres", ) diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index 9f1534a..b7d5708 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -222,7 +222,11 @@ class DuplicatedEvents(models.Model): if event is None: event = e e.masked = e != event - Event.objects.bulk_update(events, fields=["masked"]) + if e != event and e.same_uuid(event): + e.status = Event.STATUS.TRASH + if not event is None: + event.status = Event.STATUS.PUBLISHED + Event.objects.bulk_update(events, fields=["masked", "status"]) self.save() return len(events) @@ -953,6 +957,15 @@ class Event(models.Model): if Event.is_ancestor_uuid(s_uuid, e_uuid): return True return False + + def same_uuid(self, event): + if self.uuids is None or event.uuids is None: + return False + for s_uuid in self.uuids: + for e_uuid in event.uuids: + if s_uuid == e_uuid: + return True + return False def get_possibly_duplicated(self): if self.possibly_duplicated is None: diff --git a/src/agenda_culturel/templates/agenda_culturel/fix_duplicate.html b/src/agenda_culturel/templates/agenda_culturel/fix_duplicate.html index 5e6cc00..6a68eb9 100644 --- a/src/agenda_culturel/templates/agenda_culturel/fix_duplicate.html +++ b/src/agenda_culturel/templates/agenda_culturel/fix_duplicate.html @@ -29,6 +29,7 @@