parent
deaef7b650
commit
9c0e895c16
@ -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",
|
||||
)
|
||||
|
@ -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:
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
<form method="post">{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<p>Remarque : les éléments masqués qui ont la même source que l'élément à l'élément conservé seront également marqués supprimés.</p>
|
||||
<div class="grid buttons">
|
||||
<a href="{% if request.META.HTTP_REFERER %}{{ request.META.HTTP_REFERER }}{% else %}{% url 'duplicates' %}{% endif %}" role="button" class="secondary">Annuler</a>
|
||||
<input type="submit" value="Appliquer">
|
||||
|
Loading…
Reference in New Issue
Block a user