- {% thumbnail image.media "500x500" crop=False as im %}
+ {% for image in images|dictsort:"obj.pk" %}
+
{% endfor %}
@@ -33,27 +33,70 @@
{% if item.metadatas.inventory_number %}
Numéro d'inventaire : {{item.metadatas.inventory_number}}
{% endif %}
{% if item.metadatas.joconde_ref %}
{% endif %}
- {% if item.images.all.count > 1 %}
+ {% if images|length > 1 %}
Autres images pour cet objet:
- {% for image in item.images.all %}
- {% thumbnail image.media "150x150" crop=False as im_small %}
-

+ {% for image in images %}
+ {% thumbnail image.obj.media "150x150" crop=False as im_small %}
+

{% endthumbnail %}
{% endfor %}
{% endif %}
- {% for image in item.images.all %}
-
- {% include "partials/image_stats_panel.html" with image=image label="Statistiques sur cette image :" %}
+ {% for image in images %}
+
+ {% include "partials/image_stats_panel.html" with image=image.obj label="Statistiques sur cette image :" %}
{% endfor %}
Retour à la liste d'objets
- {% for image in item.images.all %}
-
- {% include "partials/image_annotations_list.html" with annotation_list=image.annotations.all header="Annotation de l'image" %}
+ {{display_image}}
+ {% for image in images %}
+
+ {% include "partials/image_annotations_list.html" with annotation_list=image.annotations header="Annotation de l'image" %}
+ {% if image.annotations %}
+
+ {% if image.annotations.has_previous or image.annotations.has_next %}
+
+ {% endif %}
+ {% endif %}
{% endfor %}
diff -r 43aa7c589048 -r 5f16c5f1efff src/iconolab/views/iconolab_objects.py
--- a/src/iconolab/views/iconolab_objects.py Thu Oct 06 15:09:18 2016 +0200
+++ b/src/iconolab/views/iconolab_objects.py Thu Oct 06 16:48:36 2016 +0200
@@ -250,12 +250,44 @@
(collection, item) = result
else:
return result(request)
+
context = super(ShowItemView, self).get_context_data(**kwargs)
+ image_guid_to_display = request.GET.get("show-image", str(item.images.first().image_guid))
+ if image_guid_to_display not in [str(guid) for guid in item.images.all().values_list("image_guid", flat=True)]:
+ image_guid_to_display = str(item.images.first().image_guid)
+ context['display_image'] = image_guid_to_display
+ try:
+ displayed_annotations_page = int(request.GET.get('page', '1'))
+ except ValueError:
+ displayed_annotations_page = 1
+ try:
+ displayed_annotations_per_page = int(request.GET.get('perpage', '10'))
+ except ValueError:
+ displayed_annotations_per_page = 10
+
context['collection_name'] = self.kwargs.get('collection_name', '')
context['item_guid'] = self.kwargs.get('image_guid', '')
context['collection'] = collection
context['item'] = item
+ context['images'] = []
for image in item.images.all():
+ if str(image.image_guid) == image_guid_to_display:
+ page = displayed_annotations_page
+ per_page = displayed_annotations_per_page
+ else:
+ page = 1
+ per_page = 10
+ annotations_paginator = Paginator(image.annotations.all(), per_page)
+ try:
+ annotations = annotations_paginator.page(page)
+ except PageNotAnInteger:
+ annotations = annotations_paginator.page(1)
+ except EmptyPage:
+ annotations = annotations_paginator.page(recent_paginator.num_pages)
+ context['images'].append({
+ 'obj' : image,
+ 'annotations': annotations
+ })
image.stats.views_count += 1
image.stats.save()
return render(request, 'iconolab/detail_item.html', context);