diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index 3bcbc7c..5b8e3a5 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -1039,17 +1039,13 @@ class Event(models.Model): if self.other_versions is None: return [] else: - return Event.objects.filter( - other_versions=self.other_versions - ).filter(~Q(status=Event.STATUS.TRASH)).exclude(pk=self.pk) + return [e for e in self.other_versions.get_duplicated() if e.pk != self.pk and e.status != Event.STATUS.TRASH] def get_other_versions(self): if self.other_versions is None: return [] else: - return Event.objects.filter( - other_versions=self.other_versions - ).exclude(pk=self.pk) + return [e for e in self.other_versions.get_duplicated() if e.pk != self.pk] def masked(self): return self.other_versions and self.other_versions.representative != self diff --git a/src/agenda_culturel/templates/agenda_culturel/page-event.html b/src/agenda_culturel/templates/agenda_culturel/page-event.html index a00aa57..df687d4 100644 --- a/src/agenda_culturel/templates/agenda_culturel/page-event.html +++ b/src/agenda_culturel/templates/agenda_culturel/page-event.html @@ -86,7 +86,7 @@ {% if event.other_versions %} {% with poss_dup=event.get_other_versions|only_allowed:user.is_authenticated %} - {% if poss_dup.count > 0 %} + {% if poss_dup|length > 0 %}
{% if event.other_versions.representative %} diff --git a/src/agenda_culturel/templates/agenda_culturel/single-event/event-single-inc.html b/src/agenda_culturel/templates/agenda_culturel/single-event/event-single-inc.html index 6ac1063..0e73b09 100644 --- a/src/agenda_culturel/templates/agenda_culturel/single-event/event-single-inc.html +++ b/src/agenda_culturel/templates/agenda_culturel/single-event/event-single-inc.html @@ -20,7 +20,7 @@

{% if event.other_versions %} {% with poss_dup=event.get_other_not_trash_versions|only_allowed:user.is_authenticated %} - {% if poss_dup.count > 0 %} + {% if poss_dup|length > 0 %}

{% if event.other_versions.representative %} cet événement existe en plusieurs versions, diff --git a/src/agenda_culturel/templatetags/event_extra.py b/src/agenda_culturel/templatetags/event_extra.py index 1cc1221..d2e0a78 100644 --- a/src/agenda_culturel/templatetags/event_extra.py +++ b/src/agenda_culturel/templatetags/event_extra.py @@ -150,6 +150,6 @@ def linebreaks2(txt): @register.filter def only_allowed(elist, is_authenticated): if not is_authenticated: - return elist.filter(status=Event.STATUS.PUBLISHED) + return [e for e in elist if e.status == Event.STATUS.PUBLISHED] else: return elist \ No newline at end of file