From 9a16cb47b06e22446e3593d8cc68186c0eac2093 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 9 May 2018 16:44:21 +0200 Subject: Display main image as first image (refs #4076) --- archaeological_operations/models.py | 6 ++- .../templates/ishtar/blocks/window_image.html | 43 +++------------------- 2 files changed, 11 insertions(+), 38 deletions(-) diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 10a281dda..aa9103f61 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -981,9 +981,13 @@ post_save.connect(operation_post_save, sender=Operation) class OperationImage(models.Model): image = models.ForeignKey(IshtarImage, on_delete=models.CASCADE) - operation = models.ForeignKey(Operation, on_delete=models.CASCADE) + operation = models.ForeignKey(Operation, on_delete=models.CASCADE, + related_name='associated_images') is_main = models.BooleanField(_(u"Main image"), default=False) + class Meta: + ordering = ('operation', '-is_main', 'image__name') + class RelationType(GeneralRelationType): diff --git a/ishtar_common/templates/ishtar/blocks/window_image.html b/ishtar_common/templates/ishtar/blocks/window_image.html index da5f149e3..751fce377 100644 --- a/ishtar_common/templates/ishtar/blocks/window_image.html +++ b/ishtar_common/templates/ishtar/blocks/window_image.html @@ -1,6 +1,7 @@ {% load i18n %}{% if item.images.count %}
- {% for image in item.images.all %} + {% for associated_image in item.associated_images.all %} + {% with image=associated_image.image %}
× {% if image.name %}

{{image.name}}

{% endif %} @@ -77,49 +78,17 @@
{% endif %}
+ {% endwith %} {% endfor %}
- {% for image in item.images.all %} + {% for associated_image in item.associated_images.all %} + {% with image=associated_image.image %} {% if output != "ODT" %}{% endif %} {% if output != "ODT" %}{% endif %} + {% endwith %} {% endfor %} - {% comment %} - - - - - - - - - - - - - - - - - - - - - - - - - - {% endcomment %}
{% endif%} -- cgit v1.2.3