sort clips

This commit is contained in:
j 2011-10-09 12:02:16 +00:00
parent ce8e012fc3
commit bb728c9369
2 changed files with 7 additions and 2 deletions

View file

@ -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():

View file

@ -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)