]> git.parisson.com Git - telemeta.git/commitdiff
fix sound_pub_items lists in index
authoryomguy <yomguy@parisson.com>
Thu, 27 Oct 2011 09:48:12 +0000 (11:48 +0200)
committeryomguy <yomguy@parisson.com>
Thu, 27 Oct 2011 09:48:12 +0000 (11:48 +0200)
telemeta/templates/telemeta_default/index.html
telemeta/web/base.py

index 7c0be01318d1f39c572c0a3caac6886829c3182b..2c944d4ff173b6772948d0c3b75b2fbf6b0bde4b 100644 (file)
@@ -14,6 +14,7 @@
     <img class="map-thumbnail" src="{% url telemeta-images "world2.png" %}" alt="{% trans "Open the geographic navigator" %}" style="width:398px" /></a>
 </div>
 
+{% if sound_pub_item %}
 <div id="module" class="module">
     <h3><img src="{% url telemeta-images "module_playlist.png" %}" alt="playlist" style="vertical-align:middle" />
     {% trans "Musical selection" %}</h3>
@@ -23,6 +24,7 @@
     </li>
     </ul>
 </div>
+{% endif %}
 
 {% include "telemeta/inc/module_revisions.html" %}
 
 {{ page_content|render_flatpage }}
 </div>
 
+{% if sound_pub_items %}
 <div style="margin-top: 1ex;">
 <h1><img src="{% url telemeta-images "playlist_title.png" %}" alt="playlists" style="vertical-align:middle" />
     {% trans "Musical selection" %}</h1>
 <table style="font-size: 90%"><tr>
-{% for item in sound_items %}
-<td width="390"><a href="{% url telemeta-item-detail item.public_id %}">{{ item }}</a>{% if item.alt_title %} ({{ item.alt_title }}){% endif %}<br /><span style="font-size: 90%">{{ item.location.fullnames|to_string }}</span><br />
+{% for item in sound_pub_items %}
+<td width="390"><a href="{% url telemeta-item-detail item.public_id %}">{{ item }}</a>{% if item.alt_title %} ({{ item.alt_title }}){% endif %}<br /><span style="font-size: 80%">{{ item.location.fullnames|to_string }}</span><br />
 <iframe width='376' height='215' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='/items/{{item.public_id }}/player/362x130/'></iframe></td>
 {% endfor %}
 </tr>
 </table>
 </div>
+{% endif %}
 
 </div>
 {% endblock %}
index 2f4f0aa78f01f2061b37acd3d3924eebf51f9221..163d632ccdb6a7e0d3e77b0546df9ce4da9625a2 100644 (file)
@@ -175,9 +175,9 @@ class GeneralView(object):
         """Render the homepage"""
         if not request.user.is_authenticated():
             template = loader.get_template('telemeta/index.html')
-            ids = [id for id in MediaItem.objects.all().values_list('id', flat=True).order_by('?')[0:3]]
-            items = MediaItem.objects.enriched().filter(pk__in=ids)
-            
+#            ids = [id for id in MediaItem.objects.all().values_list('id', flat=True).order_by('?')[0:3]]
+#            items = MediaItem.objects.enriched().filter(pk__in=ids)
+#            
             sound_items = MediaItem.objects.sound()
             sound_pub_items = []
             for item in sound_items:
@@ -185,15 +185,20 @@ class GeneralView(object):
                                                 str(item.recorded_to_date).split('-')[0]):
                     sound_pub_items.append(item)
             
-            sound_pub_item = sound_pub_items[0]
             random.shuffle(sound_pub_items)
-            if len(sound_pub_items) >= 2:
-                sound_pub_items = sound_pub_items[0:2]
-            
+            if len(sound_pub_items) != 0:
+                sound_pub_item = sound_pub_items[0]
+            else:
+                sound_pub_item = None
+            if len(sound_pub_items) == 2:
+                sound_pub_items = sound_pub_items[1]
+            if len(sound_pub_items) > 2:
+                sound_pub_items = sound_pub_items[1:3]
+                
             revisions = get_revisions(4)
             context = RequestContext(request, {
                         'page_content': pages.get_page_content(request, 'home', ignore_slash_issue=True),
-                        'items': items, 'revisions': revisions,  'sound_items': sound_pub_items, 
+                        'revisions': revisions,  'sound_pub_items': sound_pub_items, 
                         'sound_pub_item': sound_pub_item })
             return HttpResponse(template.render(context))
         else: