From c405d007ebd0369d094cf9619fac89465f04d0d1 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 16 Jun 2012 23:44:05 +0200 Subject: [PATCH] sequence duration --- pandora/sequence/models.py | 2 ++ pandora/sequence/views.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora/sequence/models.py b/pandora/sequence/models.py index e15a2851..2ef6b060 100644 --- a/pandora/sequence/models.py +++ b/pandora/sequence/models.py @@ -30,6 +30,7 @@ class Sequence(models.Model): hash = models.CharField(db_index=True, max_length=16, default='') start = models.FloatField(default=-1, db_index=True) end = models.FloatField(default=-1) + duration = models.FloatField(default=0) objects = managers.SequenceManager() @@ -37,6 +38,7 @@ class Sequence(models.Model): self.public_id = u"%s/%0.03f-%0.03f" % ( self.item.itemId, float(self.start), float(self.end) ) + self.duration = self.end - self.start if self.item: self.user = self.item.user and self.item.user.id self.sort = self.item.sort diff --git a/pandora/sequence/views.py b/pandora/sequence/views.py index e5529931..75c64526 100644 --- a/pandora/sequence/views.py +++ b/pandora/sequence/views.py @@ -41,7 +41,7 @@ def order_query(qs, sort): 'out': 'end', 'position': 'start', }.get(e['key'], e['key']) - if key not in ('start', 'end', 'mode', 'hash'): + if key not in ('duration', 'start', 'end', 'mode', 'hash'): key = 'sort__%s' % key order = '%s%s' % (operator, key) order_by.append(order)