]> git.parisson.com Git - mezzo.git/commitdiff
conditional breaking news
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 10 May 2016 14:55:57 +0000 (16:55 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 10 May 2016 14:55:57 +0000 (16:55 +0200)
app/festival/templatetags/festival_tags.py
app/templates/base.html

index 25e4ca5688dcbe283cdad7091df24408e460abb9..3b9fb5bc448bccde34461547931914ad1986fc1b 100644 (file)
@@ -32,4 +32,7 @@ def featured(*args):
 
 @register.as_tag
 def featured_breaking_news_content(*args):
-    return Featured.objects.get(id=settings.BREAKING_NEWS_FEATURED_ID).pages.all()[0].richtextpage.content
+    news = Featured.objects.get(id=settings.BREAKING_NEWS_FEATURED_ID).pages.all()
+    if news:
+        return news[0].richtextpage.content
+    return ''
index 9320c9c62eaf438bda252c97dbd5294afeb87358..68df4bacf288fafae7cc7c042988a8a167dea1ac 100644 (file)
     <div class="site__content">
         <div class="container">
             <main class="main" role="main">
-                {% if on_home %}
+                {% featured_breaking_news_content as bk_content %}
+                {% if on_home and bk_content %}
                     <div class="bk__news">
                         <div class="media bk__news__inner">
                             <div class="media-img">
                                 </span>
                             </div>
                             <div class="media-content bk__news__content">
-                                    {% featured_breaking_news_content as content %}
-                                    {{ content|safe }}
+                                    {{ bk_content|safe }}
                             </div>
 
                         </div>