From d4e89db4c10a2de9786372625a22ddfc8723a4a9 Mon Sep 17 00:00:00 2001 From: j Date: Sat, 15 Jul 2023 12:38:27 +0530 Subject: [PATCH] fix sort --- pandora/mobile/views.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pandora/mobile/views.py b/pandora/mobile/views.py index 2390c390..e3564913 100644 --- a/pandora/mobile/views.py +++ b/pandora/mobile/views.py @@ -8,6 +8,7 @@ def index(request, fragment): from item.models import Item, Annotation from edit.models import Edit from document.models import Document + from edit.views import _order_clips context = {} parts = fragment.split('/') if parts[0] in ('document', 'documents'): @@ -46,9 +47,23 @@ def index(request, fragment): link = request.build_absolute_uri('/m' + edit.get_absolute_url()) context['title'] = name context['description'] = edit.description.split('\n\n')[0] - # FIXME: use sort from parts if needed resolution = max(settings.CONFIG['video']['resolutions']) - clip = edit.get_clips().first() + if len(parts) > 3: + sort = parts[3] + if sort[0] in ('+', '-'): + sort = [{ + 'operator': sort[0], + 'key': sort[1:], + }] + else: + sort = [{ + 'operator': '+', + 'key': sort, + }] + clips = _order_clips(edit, sort) + else: + clips = edit.get_clips(request.user) + clip = clips.first() if clip: preview = '/%s/%sp%0.03f.jpg' % (clip.item.public_id, resolution, float(clip.start)) context['preview'] = request.build_absolute_uri(preview)