diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-05-09 16:44:21 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-12 08:44:18 +0200 | 
| commit | bf3810a26abe3c53fc11c4afe52e865cd5dbcc54 (patch) | |
| tree | 554896801071dd964894b78c8e74042725267a96 | |
| parent | 1835d67daf29f6b20489c779219c8d531cb1d04a (diff) | |
| download | Ishtar-bf3810a26abe3c53fc11c4afe52e865cd5dbcc54.tar.bz2 Ishtar-bf3810a26abe3c53fc11c4afe52e865cd5dbcc54.zip | |
Display main image as first image (refs #4076)
| -rw-r--r-- | archaeological_operations/models.py | 6 | ||||
| -rw-r--r-- | ishtar_common/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 %}  <div class="lightgallery-captions"> -    {% for image in item.images.all %} +    {% for associated_image in item.associated_images.all %} +    {% with image=associated_image.image %}      <div id="lightgallery-{{window_id}}-caption-{{forloop.counter0}}">          <span class="close">×</span>          {% if image.name %}<h3>{{image.name}}</h3>{% endif %} @@ -77,49 +78,17 @@          </div>          {% endif %}      </div> +    {% endwith %}      {% endfor %}  </div>  <div id="lightgallery-{{window_id}}"> -    {% for image in item.images.all %} +    {% for associated_image in item.associated_images.all %} +    {% with image=associated_image.image %}      {% if output != "ODT" %}<a data-sub-html="#lightgallery-{{window_id}}-caption-{{forloop.counter0}}" href="{{image.image.url}}"{% if not forloop.first %}                 class="lightgallery-subimage"{% endif %}>{% endif %}          <img{% if forloop.first %} class='card-img-top'{% endif %} src="{{BASE_URL}}{{image.thumbnail.url}}">      {% if output != "ODT" %}</a>{% endif %} +    {% endwith %}      {% endfor %} -    {% comment %} -    <!-- gallery test --> -    <a href="{{item.image.url}}" -       style="width:60px;display:inline-block;padding: 0.2em;"> -        <img class='card-img-top' src="{{item.thumbnail.url}}"> -    </a> -    <a href="{{item.image.url}}" -       style="width:60px;display:inline-block;padding: 0.2em;"> -        <img class='card-img-top' src="{{item.thumbnail.url}}"> -    </a> -    <a href="{{item.image.url}}" -       style="width:60px;display:inline-block;padding: 0.2em;"> -        <img class='card-img-top' src="{{item.thumbnail.url}}"> -    </a> -    <a href="{{item.image.url}}" -       style="width:60px;display:inline-block;padding: 0.2em;"> -        <img class='card-img-top' src="{{item.thumbnail.url}}"> -    </a> -    <a href="{{item.image.url}}" -       style="width:60px;display:inline-block;padding: 0.2em;"> -        <img class='card-img-top' src="{{item.thumbnail.url}}"> -    </a> -    <a href="{{item.image.url}}" -       style="width:60px;display:inline-block;padding: 0.2em;"> -        <img class='card-img-top' src="{{item.thumbnail.url}}"> -    </a> -    <a href="{{item.image.url}}" -       style="width:60px;display:inline-block;padding: 0.2em;"> -        <img class='card-img-top' src="{{item.thumbnail.url}}"> -    </a> -    <a href="{{item.image.url}}" -       style="width:60px;display:inline-block;padding: 0.2em;"> -        <img class='card-img-top' src="{{item.thumbnail.url}}"> -    </a> -    {% endcomment %}  </div>  {% endif%} | 
