From e585a0ddff5fdfc71a93929ccaf524d777be1b4c Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 15 Feb 2012 16:06:05 +0530 Subject: [PATCH] if no poster frames are selected, take some --- pandora/itemlist/models.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pandora/itemlist/models.py b/pandora/itemlist/models.py index 3c8d950e..79020bc3 100644 --- a/pandora/itemlist/models.py +++ b/pandora/itemlist/models.py @@ -130,6 +130,17 @@ class List(models.Model): def update_icon(self): frames = [] + if not self.poster_frames: + items = self.get_items(self.user).filter(rendered=True) + if items.count(): + poster_frames = [] + for i in range(0, items.count(), min(1, int(items.count()/4))): + poster_frames.append({ + 'item': items[int(i)].itemId, + 'position': items[int(i)].poster_frame + }) + self.poster_frames = tuple(poster_frames) + self.save() for i in self.poster_frames: from item.models import Item qs = Item.objects.filter(itemId=i['item'])