]> git.parisson.com Git - mezzo.git/commitdiff
fix multiple same posts
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 11 May 2016 11:31:40 +0000 (13:31 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 11 May 2016 11:31:40 +0000 (13:31 +0200)
app/festival/templates/festival/artist_detail.html
app/festival/templatetags/festival_tags.py

index b0fa36f30d772db192526a6b3cc84f9051270c95..3e4fe4ef0d369fe35534d65b877a72a064d4c057 100644 (file)
@@ -1,6 +1,6 @@
 {% extends "base.html" %}
 {% load i18n %}
-{% load mezzanine_tags keyword_tags %}
+{% load mezzanine_tags keyword_tags festival_tags %}
 
 {% block title %}
 {{ artist.name }}
     {% for video in event.videos.all %}
         {% include 'festival/inc/video_card.html' %}
     {% endfor %}
-    {% for post in event.blog_posts.all %}
+ {% endfor %}
+ {% with artist.events.all|unique_posts as posts %}
+    {% for post in posts %}
         {% include 'blog/includes/post_card.html' %}
     {% endfor %}
- {% endfor %}
+ {% endwith %}
 </div>
 {% endif %}
 {% endblock %}
index 6507c6cfbdff1ba37aacc4989ac34b0d2b78961d..ac7eeadb90634bcc4a5613c063f5653463a50e78 100644 (file)
@@ -41,13 +41,23 @@ def featured(*args):
     shuffle(featured_list)
     return featured_list
 
-@register.filter
-def get_class(obj):
-    return obj.__class__.__name__
-
 @register.as_tag
 def featured_breaking_news_content(*args):
     news = Featured.objects.get(id=settings.BREAKING_NEWS_FEATURED_ID).pages.all()
     if news:
         return news[0].richtextpage.content
     return ''
+
+@register.filter
+def get_class(obj):
+    return obj.__class__.__name__
+
+@register.filter
+def unique_posts(events):
+    post_list = []
+    for event in events:
+        for post in event.blog_posts.all():
+            print(post)
+            if not post in post_list:
+                post_list.append(post)
+    return post_list