]> git.parisson.com Git - telemeta.git/commitdiff
fix sound_pub_items lengths
authoryomguy <yomguy@parisson.com>
Thu, 27 Oct 2011 10:25:54 +0000 (12:25 +0200)
committeryomguy <yomguy@parisson.com>
Thu, 27 Oct 2011 10:25:54 +0000 (12:25 +0200)
telemeta/web/base.py

index 163d632ccdb6a7e0d3e77b0546df9ce4da9625a2..f0098ca4b27fe26994a066386a4f47549ec03e68 100644 (file)
@@ -179,21 +179,23 @@ class GeneralView(object):
 #            items = MediaItem.objects.enriched().filter(pk__in=ids)
 #            
             sound_items = MediaItem.objects.sound()
-            sound_pub_items = []
+            _sound_pub_items = []
             for item in sound_items:
                 if get_public_access(item.public_access,  str(item.recorded_from_date).split('-')[0], 
                                                 str(item.recorded_to_date).split('-')[0]):
-                    sound_pub_items.append(item)
+                    _sound_pub_items.append(item)
             
-            random.shuffle(sound_pub_items)
-            if len(sound_pub_items) != 0:
-                sound_pub_item = sound_pub_items[0]
+            random.shuffle(_sound_pub_items)
+            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]
+            if len(_sound_pub_items) == 2:
+                sound_pub_items = [_sound_pub_items[1]]
+            elif len(_sound_pub_items) > 2:
+                sound_pub_items = _sound_pub_items[1:3]
+            else:
+                sound_pub_items = None
                 
             revisions = get_revisions(4)
             context = RequestContext(request, {