From d082877968664263bff59ea7cefec647cf0b1fc7 Mon Sep 17 00:00:00 2001 From: yomguy Date: Thu, 10 Nov 2011 11:58:58 +0100 Subject: [PATCH] order item lists of collections by code and old_code, add analytics block to base.html --- telemeta/templates/telemeta_default/base.html | 4 ++++ .../telemeta_default/collection_detail.html | 14 +++++--------- telemeta/web/base.py | 8 ++++++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/telemeta/templates/telemeta_default/base.html b/telemeta/templates/telemeta_default/base.html index d64b3f98..3f3d1010 100644 --- a/telemeta/templates/telemeta_default/base.html +++ b/telemeta/templates/telemeta_default/base.html @@ -135,5 +135,9 @@ {% endblock %} {% endblock layout %} + +{% block analytics %} +{% endblock analytics %} + diff --git a/telemeta/templates/telemeta_default/collection_detail.html b/telemeta/templates/telemeta_default/collection_detail.html index d3f6bac0..cb29c98e 100644 --- a/telemeta/templates/telemeta_default/collection_detail.html +++ b/telemeta/templates/telemeta_default/collection_detail.html @@ -181,18 +181,14 @@ {% endblock technical_data %} -

Items

- {% with collection.items.enriched as items %} + +
+

Items

{% with "1" as location_name %} {% include "telemeta/inc/mediaitem_list.html" %} {% endwith %} - {% endwith %} - - +
+ {% endblock infos %} {% endblock %} diff --git a/telemeta/web/base.py b/telemeta/web/base.py index ec3fa80e..3d64bebc 100644 --- a/telemeta/web/base.py +++ b/telemeta/web/base.py @@ -343,6 +343,8 @@ class CollectionView(object): def collection_detail(self, request, public_id, template='telemeta/collection_detail.html'): collection = MediaCollection.objects.get(public_id=public_id) + items = collection.items.enriched() + items = items.order_by('code', 'old_code') if collection.public_access == 'none' and not (request.user.is_staff or request.user.is_superuser): mess = ugettext('Access not allowed') @@ -354,7 +356,8 @@ class CollectionView(object): public_access = get_public_access(collection.public_access, collection.recorded_from_year, collection.recorded_to_year) playlists = get_playlists(request) - return render(request, template, {'collection': collection, 'playlists': playlists, 'public_access': public_access}) + + return render(request, template, {'collection': collection, 'playlists': playlists, 'public_access': public_access, 'items': items}) @method_decorator(permission_required('telemeta.change_mediacollection')) def collection_edit(self, request, public_id, template='telemeta/collection_edit.html'): @@ -440,10 +443,11 @@ class ItemView(object): # Get previous and next items pks = [] items = MediaItem.objects.filter(collection=item.collection) + items = items.order_by('code', 'old_code') + if len(items) > 1: for it in items: pks.append(it.pk) - pks.sort() for pk in pks: if pk == item.pk: if pk == pks[0]: -- 2.39.5