images in item lists are now ordered by name to preserve naming convention logic at the very least, before implementing a better alternative #36
--- a/src/iconolab/models.py Thu Oct 20 15:15:44 2016 +0200
+++ b/src/iconolab/models.py Thu Oct 20 15:30:47 2016 +0200
@@ -53,6 +53,10 @@
def __str__(self):
return str(self.item_guid)+":from:"+self.collection.name
+ @property
+ def images_sorted_by_name(self):
+ return self.images.order_by("-name").all()
+
class ItemMetadata(models.Model):
item = models.OneToOneField('Item', related_name='metadatas')
authors = models.CharField(max_length=255, default="")
--- a/src/iconolab/templates/iconolab/collection_home.html Thu Oct 20 15:15:44 2016 +0200
+++ b/src/iconolab/templates/iconolab/collection_home.html Thu Oct 20 15:30:47 2016 +0200
@@ -186,7 +186,7 @@
<div class="object-infos text-center" style="margin-top: 10px;">
<a class="btn btn-default btn-xs collection-home-item-btn" href="{% url 'item_detail' collection_name item.item_guid %}"><i class="fa fa-eye"></i> Détail de l'objet</a>
</div>
- {% include "partials/item-images-preview.html" with item=item %}
+ {% include "partials/item_images_preview.html" with item=item %}
</li>
{% endfor %}
</ul>
--- a/src/iconolab/templates/partials/item-images-preview.html Thu Oct 20 15:15:44 2016 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-{% load thumbnail %}
-
-<div class="item-image-container">
- {% if item.images.count > 1 %}
- {% with item.images.first as main_image %}
- {% if main_image.wh_ratio < 1.3 %}
- <div class="item-links-portrait text-center" style="display:inline-block; margin: 10px 0px;">
- {% thumbnail main_image.media "175x300" crop=False as im %}
- <div class="main-image" style="display:inline-block">
- <a href="{% url 'item_detail' item.collection.name item.item_guid %}?show={{main_image.image_guid}}">
- <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
- </a>
- </div>
- {% endthumbnail %}
- <div class="secondary-images-container secondary-images-portrait" style="display:inline-block; margin: 10px">
- {% for secondary_image in item.images.all %}
- {% if secondary_image != main_image and forloop.counter <= 4 %}
- {% thumbnail secondary_image.media "165x90" crop=False as im %}
- <div class="secondary-image-portrait">
- <a href="{% url 'item_detail' item.collection.name item.item_guid %}?show={{secondary_image.image_guid}}">
- <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
- </a>
- </div>
- {% endthumbnail %}
- {% endif %}
- {% endfor %}
- </div>
- </div>
- {% else %}
- <div class="item-links-landscape text-center">
- {% thumbnail main_image.media "350x150" crop=False as im %}
- <div class="main-image" style="display:inline-block">
- <a href="{% url 'item_detail' item.collection.name item.item_guid %}?show={{main_image.image_guid}}">
- <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
- </a>
- </div>
- {% endthumbnail %}
- <div class="secondary-images-container secondary-images-landscape" style="margin: 10px">
- {% for secondary_image in item.images.all %}
- {% if secondary_image != main_image and forloop.counter <= 3 %}
- {% thumbnail secondary_image.media "140x140" crop=False as im %}
- <div class="secondary-image-landscape pull-left" style="display:inline-block">
- <a href="{% url 'item_detail' item.collection.name item.item_guid %}?show={{secondary_image.image_guid}}">
- <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
- </a>
- </div>
- {% endthumbnail %}
- {% endif %}
- {% endfor %}
- </div>
- </div>
- {% endif %}
- {% endwith %}
- {% else %}
- {% with item.images.first as main_image %}
- <div class="item-links text-center" style="display:inline-block; margin: 10px 0px;">
- {% thumbnail main_image.media "350x210" crop=False as im %}
- <a href="{% url 'item_detail' item.collection.name item.item_guid %}?show={{main_image.image_guid}}">
- <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
- </a>
- {% endthumbnail %}
- </div>
- {% endwith %}
- {% endif %}
-</div>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/iconolab/templates/partials/item_images_preview.html Thu Oct 20 15:30:47 2016 +0200
@@ -0,0 +1,65 @@
+{% load thumbnail %}
+
+<div class="item-image-container">
+ {% if item.images.count > 1 %}
+ {% with item.images_sorted_by_name.first as main_image %}
+ {% if main_image.wh_ratio < 1.3 %}
+ <div class="item-links-portrait text-center" style="display:inline-block; margin: 10px 0px;">
+ {% thumbnail main_image.media "175x300" crop=False as im %}
+ <div class="main-image" style="display:inline-block">
+ <a href="{% url 'item_detail' item.collection.name item.item_guid %}?show={{main_image.image_guid}}">
+ <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
+ </a>
+ </div>
+ {% endthumbnail %}
+ <div class="secondary-images-container secondary-images-portrait" style="display:inline-block; margin: 10px">
+ {% for secondary_image in item.images.all %}
+ {% if secondary_image != main_image and forloop.counter <= 4 %}
+ {% thumbnail secondary_image.media "165x90" crop=False as im %}
+ <div class="secondary-image-portrait">
+ <a href="{% url 'item_detail' item.collection.name item.item_guid %}?show={{secondary_image.image_guid}}">
+ <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
+ </a>
+ </div>
+ {% endthumbnail %}
+ {% endif %}
+ {% endfor %}
+ </div>
+ </div>
+ {% else %}
+ <div class="item-links-landscape text-center">
+ {% thumbnail main_image.media "350x150" crop=False as im %}
+ <div class="main-image" style="display:inline-block">
+ <a href="{% url 'item_detail' item.collection.name item.item_guid %}?show={{main_image.image_guid}}">
+ <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
+ </a>
+ </div>
+ {% endthumbnail %}
+ <div class="secondary-images-container secondary-images-landscape" style="margin: 10px">
+ {% for secondary_image in item.images.all %}
+ {% if secondary_image != main_image and forloop.counter <= 3 %}
+ {% thumbnail secondary_image.media "140x140" crop=False as im %}
+ <div class="secondary-image-landscape pull-left" style="display:inline-block">
+ <a href="{% url 'item_detail' item.collection.name item.item_guid %}?show={{secondary_image.image_guid}}">
+ <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
+ </a>
+ </div>
+ {% endthumbnail %}
+ {% endif %}
+ {% endfor %}
+ </div>
+ </div>
+ {% endif %}
+ {% endwith %}
+ {% else %}
+ {% with item.images.first as main_image %}
+ <div class="item-links text-center" style="display:inline-block; margin: 10px 0px;">
+ {% thumbnail main_image.media "350x210" crop=False as im %}
+ <a href="{% url 'item_detail' item.collection.name item.item_guid %}?show={{main_image.image_guid}}">
+ <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
+ </a>
+ {% endthumbnail %}
+ </div>
+ {% endwith %}
+ {% endif %}
+</div>
\ No newline at end of file
--- a/src/iconolab/templates/search/image_search.html Thu Oct 20 15:15:44 2016 +0200
+++ b/src/iconolab/templates/search/image_search.html Thu Oct 20 15:30:47 2016 +0200
@@ -34,7 +34,7 @@
{% for item in page_obj.object_list %}
<li class="search-image-list-li container panel panel-default col-md-12">
<div class=" pull-left search-image-container row search-image-list-image-container col-md-5" style="vertical-align:middle; display: inline-block; padding-top:10px; padding-bottom:10px;">
- {% include "partials/item-images-preview.html" with item=item.object %}
+ {% include "partials/item_images_preview.html" with item=item.object %}
</div>
<div class="search-item-info text-left col-md-7" style="display:inline-block; margin: 10px 0px;">
<h1 class="search-title" style="display:inline-block; margin-top: 0px;"><small>Métadonnées de l'objet</small></h1>