Événements possiblement dupliqués
+-
+ {% for e in events %}
+
- {{ e.start_day }}{% if e.start_time %} à {{ e.start_time }}{% endif %} : {{ e.title }} créé le {{ e.created_date }} + {% endfor %} +
diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index a74eecf..e920bea 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -107,6 +107,9 @@ class DuplicatedEvents(models.Model): def nb_duplicated(self): return Event.objects.filter(possibly_duplicated=self).count() + def get_duplicated(self): + return Event.objects.filter(possibly_duplicated=self) + def merge_into(self, other): # for all objects associated to this group for e in Event.objects.filter(possibly_duplicated=self): @@ -129,6 +132,19 @@ class DuplicatedEvents(models.Model): return result + def get_item_comparion(self, attr): + values = [getattr(e, attr) for e in self.get_duplicated()] + if isinstance(values[0], list): + hashable_values = "; ".join([str(v) for v in values]) + else: + hashable_values = values + if len(set(hashable_values)) == 1: + return { "similar": True, "key": attr, "values": values[0] } + else: + return { "similar": False, "key": attr, "values": values } + + def get_items_comparison(self): + return [self.get_item_comparion(e) for e in Event.data_fields() + ["local_image"]] class Event(models.Model): @@ -489,7 +505,7 @@ class Event(models.Model): def data_fields(): - return ["title", "location", "start_day", "start_time", "end_day", "end_time", "description", "image", "image_alt", "image_alt", "reference_urls", "recurrences"] + return ["title", "location", "start_day", "start_time", "end_day", "end_time", "description", "image", "image_alt", "reference_urls", "recurrences"] def same_event_by_data(self, other): for attr in Event.data_fields(): diff --git a/src/agenda_culturel/static/style.scss b/src/agenda_culturel/static/style.scss index 9b6464c..6590345 100644 --- a/src/agenda_culturel/static/style.scss +++ b/src/agenda_culturel/static/style.scss @@ -627,9 +627,9 @@ aside nav a.selected { background: var(--primary-focus); } aside nav a.badge { - float: right; z-index: 1; margin-top: -2em; + float: right; } .body-fixed { @@ -720,7 +720,50 @@ aside nav a.badge { } article article { - margin-top: 3em; - margin-bottom: 3em; + margin: 3em 0.5em; padding: 0.6em 0.2em; +} + + +.badge-circle { + display: block; + float: left; + width: 2.5em; + height: 2.5em; + line-height: 2.5em; + text-align: center; + border-radius: 50%; + color: var(--secondary-inverse); + background: $primary-500; +} + + +.entete-badge { + grid-template-columns: 2.5em repeat(auto-fit, minmax(0%, 1fr)); + + .badge-large { + @extend .badge-circle; + font-size: 140%; + } + li { + list-style-type: none; + } +} + +.comparison-item { + margin: 0.4em; + .duplicated { + padding: 0.5em; + background: rgba(255, 0, 76, 0.1); + border-radius: 0.5em; + } + + .badge-small { + @extend .badge-circle; + font-size: 70%; + width: 2em; + height: 2em; + line-height: 2em; + margin-right: 1em; + } } \ No newline at end of file diff --git a/src/agenda_culturel/templates/agenda_culturel/duplicates.html b/src/agenda_culturel/templates/agenda_culturel/duplicates.html new file mode 100644 index 0000000..4ae958f --- /dev/null +++ b/src/agenda_culturel/templates/agenda_culturel/duplicates.html @@ -0,0 +1,62 @@ +{% extends "agenda_culturel/page.html" %} + +{% load utils_extra %} + +{% block title %}Événements possiblement dupliqués{% endblock %} + +{% load cat_extra %} +{% block entete_header %} + {% css_categories %} +{% endblock %} + +{% block content %} +
Les événements ci-dessous ont été détectés ou signalés comme possiblement dupliqué. + Les éléments qui diffèrent ont été dupliqués et mis en évidence.
+