From bb728c9369fc32365504ed850f5d4b8e42167187 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 9 Oct 2011 12:02:16 +0000 Subject: [PATCH] sort clips --- pandora/clip/models.py | 3 ++- pandora/clip/views.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pandora/clip/models.py b/pandora/clip/models.py index 656170fd..756090ac 100644 --- a/pandora/clip/models.py +++ b/pandora/clip/models.py @@ -50,13 +50,14 @@ class Clip(models.Model): def json(self, keys=None): j = {} - clip_keys = ('id', 'in', 'out', 'created', 'modified', + clip_keys = ('id', 'in', 'out', 'position', 'created', 'modified', 'hue', 'saturation', 'lightness', 'volume') for key in clip_keys: j[key] = getattr(self, { 'id': 'public_id', 'in': 'start', 'out': 'end', + 'position': 'start', }.get(key, key)) if keys: for key in j.keys(): diff --git a/pandora/clip/views.py b/pandora/clip/views.py index cd5aefae..3147ae19 100644 --- a/pandora/clip/views.py +++ b/pandora/clip/views.py @@ -31,9 +31,13 @@ def order_query(qs, sort): operator = e['operator'] if operator != '-': operator = '' + clip_keys = ('start', 'end', 'hue', 'saturation', 'lightness', 'volume' + 'annotations__value') key = { 'in': 'start', 'out': 'end', + 'position': 'start', + 'text': 'annotations__value', }.get(e['key'], e['key']) if key.startswith('clip:'): key = e['key'][len('clip:'):] @@ -41,7 +45,7 @@ def order_query(qs, sort): 'text': 'annotations__value', 'position': 'start', }.get(key, key) - elif key not in ('start', 'end', 'annotations__value'): + elif key not in clip_keys: #key mgith need to be changed, see order_sort in item/views.py key = "item__sort__%s" % key order = '%s%s' % (operator, key)