]> git.ipfire.org Git - ipfire.org.git/commitdiff
Add option to show no banner at all.
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 22 Apr 2010 13:29:05 +0000 (15:29 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 22 Apr 2010 13:29:05 +0000 (15:29 +0200)
www/templates/modules/sidebar-banner.html
www/webapp/banners.py

index 7a10b3b7afd3ab2ed8df6b2fff2d8ce8d7bb2b1f..fb891fcae25e7d404be4ebfaed73d9690f037ec8 100644 (file)
@@ -1,5 +1,7 @@
-<h4>{{ item.title }}</h4>
+{% if item %}
+       <h4>{{ item.title }}</h4>
 
-<a href="{{ item.link }}" {% if item.link.startswith("http://") %}target="_blank" {% end %}>
-       <img src="{{ static_url(item.uri) }}" border="0" alt="{{ _("Banner") }}" />
-</a>
+       <a href="{{ item.link }}" {% if item.link.startswith("http://") %}target="_blank" {% end %}>
+               <img src="{{ static_url(item.uri) }}" border="0" alt="{{ _("Banner") }}" />
+       </a>
+{% end %}
index ba21ab99de59bbcb9587b78887fc6cfaa786ba27..65aeac8d361849d131528e15f35e233090ac55fb 100644 (file)
@@ -20,7 +20,8 @@ class Banners(object):
                        self.items.append(Item(**_stringify(item)))
 
        def get(self):
-               return random.choice(self.items)
+               if self.items:
+                       return random.choice(self.items)
 
 
 banners = Banners("banners.json")