# HG changeset patch # User durandn # Date 1476359503 -7200 # Node ID b67ea0d6c621e0b416829f31ac0ad7865487124e # Parent b7e752e2e6694462c84ba88f685ca70095c97df5 search page design and item preview for multiple images #36 diff -r b7e752e2e669 -r b67ea0d6c621 src/iconolab/models.py --- a/src/iconolab/models.py Wed Oct 12 15:06:53 2016 +0200 +++ b/src/iconolab/models.py Thu Oct 13 13:51:43 2016 +0200 @@ -125,6 +125,10 @@ return str(self.image_guid)+":"+self.name @property + def wh_ratio(self): + return self.width / self.height + + @property def collection(self): return self.item.collection.name diff -r b7e752e2e669 -r b67ea0d6c621 src/iconolab/search_indexes/forms.py --- a/src/iconolab/search_indexes/forms.py Wed Oct 12 15:06:53 2016 +0200 +++ b/src/iconolab/search_indexes/forms.py Thu Oct 13 13:51:43 2016 +0200 @@ -1,16 +1,18 @@ from django import forms from haystack.forms import SearchForm -from iconolab.models import Item, Annotation +from iconolab.models import Item, Annotation, Collection class IconolabSearchForm(SearchForm): - model_type = forms.ChoiceField(required=False, choices=(("images","Image"), ("annotations","Annotation")) ) + model_type = forms.ChoiceField(required=False, choices=(("images","Images"), ("annotations","Annotations")) ) def __init__(self, *args, **kwargs): self.collection_name = kwargs.pop("collection_name") + if self.collection_name and Collection.objects.filter(name=self.collection_name).exists(): + self.collection = Collection.objects.get(name=self.collection_name) selected_model_type = kwargs.pop("model_type", None) if selected_model_type is not None: diff -r b7e752e2e669 -r b67ea0d6c621 src/iconolab/templates/iconolab/collection_home.html --- a/src/iconolab/templates/iconolab/collection_home.html Wed Oct 12 15:06:53 2016 +0200 +++ b/src/iconolab/templates/iconolab/collection_home.html Thu Oct 13 13:51:43 2016 +0200 @@ -186,67 +186,7 @@
Détail de l'objet
- {% if item.images.count > 1 %} - {% with item.images.first as main_image %} - {% if main_image.height > main_image.width %} - - {% else %} - - {% endif %} - {% endwith %} - {% else %} - {% with item.images.first as main_image %} - - {% endwith %} - {% endif %} + {% include "partials/item-images-preview.html" with item=item %} {% endfor %} diff -r b7e752e2e669 -r b67ea0d6c621 src/iconolab/templates/partials/item-images-preview.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/iconolab/templates/partials/item-images-preview.html Thu Oct 13 13:51:43 2016 +0200 @@ -0,0 +1,65 @@ +{% load thumbnail %} + +
+ {% if item.images.count > 1 %} + {% with item.images.first as main_image %} + {% if main_image.wh_ratio < 1.3 %} + + {% else %} + + {% endif %} + {% endwith %} + {% else %} + {% with item.images.first as main_image %} + + {% endwith %} + {% endif %} +
\ No newline at end of file diff -r b7e752e2e669 -r b67ea0d6c621 src/iconolab/templates/search/annotation_search.html --- a/src/iconolab/templates/search/annotation_search.html Wed Oct 12 15:06:53 2016 +0200 +++ b/src/iconolab/templates/search/annotation_search.html Thu Oct 13 13:51:43 2016 +0200 @@ -7,106 +7,112 @@

Recherche

-
- - + +
+
+
Chercher
+ +
dans les
+ + {% if form.collection_name %} +
du fonds {{form.collection.verbose_name}}
+ {% else %} +
du site
+ {% endif %} +
+
+ + +

{{ page_obj.paginator.count }} annotation(s)

+
+ + + + + + + + + + {% for result in page_obj.object_list %} - - - + + + + + + + - + {% endfor %}
TitreAuteurCréée leRévisée leContributeursStatistiques
{{ form.as_p }} - - +
+ {% thumbnail result.object.image.media "150x150" crop=False as im %} + + + + + + + + + {% endthumbnail %} +
+
{{ result.object.current_revision.title }}{{ result.object.author }}{{ result.object.created|date:'d-m-Y' }}{{ result.object.current_revision.created|date:'d-m-Y' }} + {% for contributor in result.object.stats.contributors.all %} + {{ contributor.username }}{% if not forloop.last %}, {% endif %} + {% endfor %} + + {% include "partials/annotation_stats_panel.html" with annotation=result.object %} +
- -

{{ page_obj.paginator.count }} annotation(s)

- - + + {% if page_obj.has_previous or page_obj.has_next %} + - {% if page_obj.has_previous or page_obj.has_next %} - + {% endfor %} + + {% if page_obj.has_next %} +
  • + + + +
  • {% endif %} - + + {% endif %} {% endblock %} \ No newline at end of file diff -r b7e752e2e669 -r b67ea0d6c621 src/iconolab/templates/search/default_search.html --- a/src/iconolab/templates/search/default_search.html Wed Oct 12 15:06:53 2016 +0200 +++ b/src/iconolab/templates/search/default_search.html Thu Oct 13 13:51:43 2016 +0200 @@ -7,16 +7,24 @@

    Recherche

    -
    - - - - - - -
    {{ form.as_p }} - -
    - -
    +
    +
    +
    +
    Chercher
    + +
    dans les
    + + {% if form.collection_name %} +
    du fonds {{form.collection.verbose_name}}
    + {% else %} +
    du site
    + {% endif %} +
    +
    + +
    > {% endblock %} \ No newline at end of file diff -r b7e752e2e669 -r b67ea0d6c621 src/iconolab/templates/search/image_search.html --- a/src/iconolab/templates/search/image_search.html Wed Oct 12 15:06:53 2016 +0200 +++ b/src/iconolab/templates/search/image_search.html Thu Oct 13 13:51:43 2016 +0200 @@ -5,93 +5,40 @@ {% block content %} -

    Recherche

    +

    Recherche

    -
    - - - - - - - -
    {{ form.as_p }} - -
    -
    +
    +
    +
    +
    Chercher
    + +
    dans les
    + + {% if form.collection_name %} +
    du fonds {{form.collection.verbose_name}}
    + {% else %} +
    du site
    + {% endif %} +
    +
    + +

    {{ page_obj.paginator.count }} image(s)

      {% for item in page_obj.object_list %}
    • -
      - {% if item.object.images.count > 1 %} - {% with item.object.images.first as main_image %} - {% if main_image.height > main_image.width %} - - {% else %} - - {% endif %} - {% endwith %} - {% else %} - {% with item.images.first as main_image %} - - {% endwith %} - {% endif %} -
      - -

      Métadonnées de l'objet

      +
      + {% include "partials/item-images-preview.html" with item=item.object %} +
      +
      +

      Métadonnées de l'objet

      + Détail de l'objet {% if item.object.metadatas.designation %}

      Désignation : {{item.object.metadatas.designation}}

      {% endif %} {% if item.object.metadatas.authors %}

      Auteur(s) : {{item.object.metadatas.designation}}

      {% endif %} {% if item.object.metadatas.conservation_location %}

      Conservé à : {{item.object.metadatas.conservation_location}}

      {% endif %} @@ -103,7 +50,6 @@ {% if item.object.metadatas.photo_credits %}
      Crédits photographiques : {{item.object.metadatas.photo_credits}}
      {% endif %} {% if item.object.metadatas.inventory_number %}
      Numéro d'inventaire : {{item.object.metadatas.inventory_number}}
      {% endif %}
      -
    • {% endfor %}