sort clips
This commit is contained in:
parent
ce8e012fc3
commit
bb728c9369
2 changed files with 7 additions and 2 deletions
|
@ -50,13 +50,14 @@ class Clip(models.Model):
|
||||||
|
|
||||||
def json(self, keys=None):
|
def json(self, keys=None):
|
||||||
j = {}
|
j = {}
|
||||||
clip_keys = ('id', 'in', 'out', 'created', 'modified',
|
clip_keys = ('id', 'in', 'out', 'position', 'created', 'modified',
|
||||||
'hue', 'saturation', 'lightness', 'volume')
|
'hue', 'saturation', 'lightness', 'volume')
|
||||||
for key in clip_keys:
|
for key in clip_keys:
|
||||||
j[key] = getattr(self, {
|
j[key] = getattr(self, {
|
||||||
'id': 'public_id',
|
'id': 'public_id',
|
||||||
'in': 'start',
|
'in': 'start',
|
||||||
'out': 'end',
|
'out': 'end',
|
||||||
|
'position': 'start',
|
||||||
}.get(key, key))
|
}.get(key, key))
|
||||||
if keys:
|
if keys:
|
||||||
for key in j.keys():
|
for key in j.keys():
|
||||||
|
|
|
@ -31,9 +31,13 @@ def order_query(qs, sort):
|
||||||
operator = e['operator']
|
operator = e['operator']
|
||||||
if operator != '-':
|
if operator != '-':
|
||||||
operator = ''
|
operator = ''
|
||||||
|
clip_keys = ('start', 'end', 'hue', 'saturation', 'lightness', 'volume'
|
||||||
|
'annotations__value')
|
||||||
key = {
|
key = {
|
||||||
'in': 'start',
|
'in': 'start',
|
||||||
'out': 'end',
|
'out': 'end',
|
||||||
|
'position': 'start',
|
||||||
|
'text': 'annotations__value',
|
||||||
}.get(e['key'], e['key'])
|
}.get(e['key'], e['key'])
|
||||||
if key.startswith('clip:'):
|
if key.startswith('clip:'):
|
||||||
key = e['key'][len('clip:'):]
|
key = e['key'][len('clip:'):]
|
||||||
|
@ -41,7 +45,7 @@ def order_query(qs, sort):
|
||||||
'text': 'annotations__value',
|
'text': 'annotations__value',
|
||||||
'position': 'start',
|
'position': 'start',
|
||||||
}.get(key, key)
|
}.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 mgith need to be changed, see order_sort in item/views.py
|
||||||
key = "item__sort__%s" % key
|
key = "item__sort__%s" % key
|
||||||
order = '%s%s' % (operator, key)
|
order = '%s%s' % (operator, key)
|
||||||
|
|
Loading…
Reference in a new issue