From ad03e67365269b4388e657b83e46c7416f1cf332 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 7 Nov 2011 16:05:21 +0100 Subject: [PATCH 1/2] sort level --- pandora/user/models.py | 4 ++++ pandora/user/views.py | 1 + 2 files changed, 5 insertions(+) diff --git a/pandora/user/models.py b/pandora/user/models.py index 4c32a39f9..7b580ca1a 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -23,6 +23,7 @@ class SessionData(models.Model): firstseen = models.DateTimeField(auto_now_add=True, db_index=True) lastseen = models.DateTimeField(auto_now=True, db_index=True) username = models.CharField(max_length=255, null=True, db_index=True) + level = models.IntegerField(default=0) timesseen = models.IntegerField(default=0) ip = models.CharField(default='', max_length=255) @@ -40,7 +41,10 @@ class SessionData(models.Model): def save(self, *args, **kwargs): if self.user: self.username = self.user.username + self.level = self.user.get_profile().level self.firstseen = self.user.date_joined + else: + self.level = 0 super(SessionData, self).save(*args, **kwargs) @classmethod diff --git a/pandora/user/views.py b/pandora/user/views.py index 39479d031..a560c90a7 100644 --- a/pandora/user/views.py +++ b/pandora/user/views.py @@ -422,6 +422,7 @@ def order_query(qs, sort): 'useragent': 'useragent', 'username': 'username', 'windowsize': 'windowsize', + 'level': 'level', }.get(e['key'], 'user__profile__%s'%e['key']) if key == 'user__profile__numberoflists': qs = qs.annotate(numberoflists=Sum('user__lists')) From 9c173ba0a331b50141b1b03e32dafac0ceba1b3a Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 7 Nov 2011 16:32:50 +0100 Subject: [PATCH 2/2] dont get color for clips outside item duration --- pandora/clip/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora/clip/models.py b/pandora/clip/models.py index 10c0056ca..e8c194578 100644 --- a/pandora/clip/models.py +++ b/pandora/clip/models.py @@ -11,7 +11,9 @@ import managers class MetaClip: def update_calculated_values(self): - self.duration = self.end - self.start + start = min(self.start, self.item.sort.duration) + end = min(self.end, self.item.sort.duration) + self.duration = end - start if self.duration > 0: self.hue, self.saturation, self.lightness = extract.average_color( self.item.timeline_prefix, self.start, self.end)