From 13bd56027c0b1c8e19742ac025d18b1bdf776847 Mon Sep 17 00:00:00 2001 From: yomguy Date: Thu, 27 Oct 2011 12:25:54 +0200 Subject: [PATCH] fix sound_pub_items lengths --- telemeta/web/base.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/telemeta/web/base.py b/telemeta/web/base.py index 163d632c..f0098ca4 100644 --- a/telemeta/web/base.py +++ b/telemeta/web/base.py @@ -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, { -- 2.39.5