--- a/src/iconolab/models.py Tue Oct 11 12:18:52 2016 +0200
+++ b/src/iconolab/models.py Wed Oct 12 13:30:13 2016 +0200
@@ -162,8 +162,6 @@
for annotation in self.annotations.all():
revision_tags = json.loads(annotation.current_revision.get_tags_json())
tag_list += [tag_infos['tag_label'] for tag_infos in revision_tags if tag_infos.get('tag_label') is not None] #deal with
- print("tag_list")
- print(tag_list)
return tag_list
class AnnotationManager(models.Manager):
--- a/src/iconolab/search_indexes/__init__.py Tue Oct 11 12:18:52 2016 +0200
+++ b/src/iconolab/search_indexes/__init__.py Wed Oct 12 13:30:13 2016 +0200
@@ -1,2 +1,2 @@
-from .indexes import AnnotationIndex, ImageIndex
-__all__ = ['AnnotationIndex', 'ImageIndex', 'RevisionSignalProcessor']
\ No newline at end of file
+from .indexes import AnnotationIndex, ItemIndex
+__all__ = ['AnnotationIndex', 'ItemIndex', 'RevisionSignalProcessor']
\ No newline at end of file
--- a/src/iconolab/search_indexes/forms.py Tue Oct 11 12:18:52 2016 +0200
+++ b/src/iconolab/search_indexes/forms.py Wed Oct 12 13:30:13 2016 +0200
@@ -1,6 +1,6 @@
from django import forms
from haystack.forms import SearchForm
-from iconolab.models import Image, Annotation
+from iconolab.models import Item, Annotation
@@ -31,9 +31,9 @@
def get_model_type_queryset(self, qs, model_type):
if model_type == 'images':
- qs = qs.models(Image).load_all_queryset(Image, Image.objects.select_related('item', 'item__metadatas'))
+ qs = qs.models(Item).load_all_queryset(Item, Item.objects.select_related('collection', 'metadatas'))
if model_type == 'annotations':
- qs = qs.models(Annotation).load_all_queryset(Annotation, Annotation.objects.select_related('image', 'stats', 'current_revision', 'author'))
+ qs = qs.models(Annotation).load_all_queryset(Annotation, Annotation.objects.select_related('image', 'image__item', 'image__item__collection', 'stats', 'current_revision', 'author'))
if self.collection_name is not None:
qs = qs.filter(collection = self.collection_name)
--- a/src/iconolab/search_indexes/indexes.py Tue Oct 11 12:18:52 2016 +0200
+++ b/src/iconolab/search_indexes/indexes.py Wed Oct 12 13:30:13 2016 +0200
@@ -1,39 +1,37 @@
from django.utils import timezone
from haystack import indexes
-from iconolab.models import Annotation, Image
+from iconolab.models import Annotation, Item
-class ImageIndex(indexes.SearchIndex, indexes.Indexable):
+class ItemIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
collection = indexes.CharField(model_attr="collection")
- authors = indexes.CharField(model_attr="authors")
- school = indexes.CharField(model_attr="school")
- designation = indexes.CharField(model_attr="designation")
- datation = indexes.CharField(model_attr="datation")
- technics = indexes.CharField(model_attr="technics")
- measurements = indexes.CharField(model_attr="measurements")
-
- create_or_usage_location = indexes.CharField(model_attr="item__metadatas__create_or_usage_location")
- discovery_context = indexes.CharField(model_attr="item__metadatas__discovery_context")
- conservation_location = indexes.CharField(model_attr="item__metadatas__conservation_location")
+ authors = indexes.CharField(model_attr="metadatas__authors")
+ school = indexes.CharField(model_attr="metadatas__school")
+ designation = indexes.CharField(model_attr="metadatas__designation")
+ datation = indexes.CharField(model_attr="metadatas__datation")
+ technics = indexes.CharField(model_attr="metadatas__technics")
+ measurements = indexes.CharField(model_attr="metadatas__measurements")
+ create_or_usage_location = indexes.CharField(model_attr="metadatas__create_or_usage_location")
+ discovery_context = indexes.CharField(model_attr="metadatas__discovery_context")
+ conservation_location = indexes.CharField(model_attr="metadatas__conservation_location")
- tags = indexes.MultiValueField(model_attr="tag_labels")
+ #tags = indexes.MultiValueField(model_attr="tag_labels")
def get_model(self):
- return Image
+ return Item
def index_queryset(self, using=None):
- return self.get_model().objects.filter(created__lte=timezone.now())
+ return self.get_model().objects.filter()
class AnnotationIndex(indexes.SearchIndex, indexes.Indexable):
##indexed field
text = indexes.CharField(document=True, use_template=True)
-
title = indexes.CharField(model_attr="current_revision__title")
description = indexes.CharField(model_attr="current_revision__description")
- collection = indexes.CharField(model_attr="collection")
+ collection = indexes.CharField(model_attr="image__item__collection")
tags = indexes.MultiValueField(model_attr="tag_labels")
## tags
--- a/src/iconolab/search_indexes/query.py Tue Oct 11 12:18:52 2016 +0200
+++ b/src/iconolab/search_indexes/query.py Wed Oct 12 13:30:13 2016 +0200
@@ -1,5 +1,5 @@
from haystack.query import RelatedSearchQuerySet
-from iconolab.models import Annotation, Image
+from iconolab.models import Annotation, Item
from pprint import pprint
class IconolabRelatedQuerySet(RelatedSearchQuerySet):
--- a/src/iconolab/search_indexes/views.py Tue Oct 11 12:18:52 2016 +0200
+++ b/src/iconolab/search_indexes/views.py Wed Oct 12 13:30:13 2016 +0200
@@ -11,7 +11,6 @@
form_class = IconolabSearchForm
queryset = RelatedSearchQuerySet()
template_name = "search/default_search.html"
- paginate_by = 10
load_all = True
templates_map = {
@@ -41,6 +40,7 @@
def get(self, request, *args, **kwargs):
self.model_type = request.GET.get('model_type', None)
+ self.paginate_by = request.GET.get('perpage', 10)
collection_name = self.kwargs.get('collection_name', None)
if self.model_type is not None:
--- a/src/iconolab/templates/search/annotation_search.html Tue Oct 11 12:18:52 2016 +0200
+++ b/src/iconolab/templates/search/annotation_search.html Wed Oct 12 13:30:13 2016 +0200
@@ -7,7 +7,7 @@
<h2>Recherche</h2>
- <form method="get" action=".">
+ <form method="get" action="{% url 'search_indexes:haystack_search' %}">
<table>
<tr>
@@ -20,42 +20,93 @@
</table>
- <h3><strong>{{ page_obj.paginator.count }}</strong> annotation(s)</h3>
-
+ <h3><strong>{{ page_obj.paginator.count }}</strong> annotation(s)</h3>
+ <ul class="annotation-list-wrapper list-inline">
+ {% if not page_obj.object_list %}
+ <h3 class="text-center"><small>Aucune annotation à afficher</small></p>
+ {% else %}
+ <table class="table table-condensed">
+ <thead>
+ <th></th>
+ <th>Titre</th>
+ <th>Auteur</th>
+ <th>Créée le</th>
+ <th>Révisée le</th>
+ <th>Contributeurs</th>
+ <th>Statistiques</th>
+ </thead>
{% for result in page_obj.object_list %}
-
- {% thumbnail result.object.image.media "400x400" crop=False as im %}
- <div class="annotation-item result" style="position:relative;">
-
- <a href="{% url 'annotation_detail' result.object.collection result.object.image.image_guid result.object.annotation_guid %}">
- <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
- <svg width="{{ im.width }}" height="{{ im.height }}" version="1.1" style="position:absolute; top:0px; left: 0px">
- <g transform="matrix({% transform_matrix im_width=im.width im_height=im.height max_x=100 max_y=100 %})">
- <path d="{{ result.object.current_revision.fragment|clean_path }}" opacity="0.7" fill="orange"></path>
- </g>
- </svg>
- </a>
- </div>
- {% endthumbnail %}
-
- <p>
- <a href="{% url 'annotation_detail' result.object.collection result.object.image.image_guid result.object.annotation_guid %}">{{ result.object.current_revision.title }}</a>
- </p>
-
- <div class="fragment-infos">
- <a class="btn btn-default btn-xs collection-home-btn" href="{% url 'annotation_detail' result.object.collection result.object.image.image_guid result.object.annotation_guid %}"><i class="fa fa-eye"></i> Voir l'annotation</a>
- </div>
-
- {% empty %}
- <p>Aucune annotation n'a été trouvée.</p>
+ <tr>
+ <td>
+ <div class="fragment-container" style="position: relative">
+ {% thumbnail result.object.image.media "150x150" crop=False as im %}
+ <a href="{% url 'annotation_detail' result.object.image.item.collection.name result.object.image.image_guid result.object.annotation_guid %}">
+ <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
+ <svg width="{{ im.width }}" height="{{ im.height }}" version="1.1" style="position:absolute; top:0px; left: 0px">
+ <g transform="matrix({% transform_matrix im_width=im.width im_height=im.height max_x=100 max_y=100 %})">
+ <path d="{{ result.object.current_revision.fragment|clean_path }}" opacity="0.7" fill="orange"></path>
+ </g>
+ </svg>
+ </a>
+ {% endthumbnail %}
+ </div>
+ </td>
+ <td>{{ result.object.current_revision.title }}</td>
+ <td><a href="{% url 'user_home' result.object.author.id %}" style="color:#000000">{{ result.object.author }}</a></td>
+ <td>{{ result.object.created|date:'d-m-Y' }}</td>
+ <td>{{ result.object.current_revision.created|date:'d-m-Y' }}</td>
+ <td>
+ {% for contributor in result.object.stats.contributors.all %}
+ <a href="{% url 'user_home' contributor.id %}" style="color:#000000">{{ contributor.username }}</a>{% if not forloop.last %}, {% endif %}
+ {% endfor %}
+ </td>
+ <td>
+ {% include "partials/annotation_stats_panel.html" with annotation=result.object %}
+ </td>
+ </tr>
{% endfor %}
-
- {% if page_obj.has_previous or page_obj.has_next %}
- <div>
- {% if page_obj.has_previous %}<a href="?q={{ query }}&page={{ page_obj.previous_page_number }}">{% endif %}« Previous{% if page_obj.has_previous %}</a>{% endif %}
- |
- {% if page_obj.has_next %}<a href="?q={{ query }}&page={{ page_obj.next_page_number }}">{% endif %}Next »{% if page_obj.has_next %}</a>{% endif %}
- </div>
- {% endif %}
+ </table>
+ {% endif %}
+ </ul>
+ <ul class="pagination pull-right items-perpage" style="margin-left: 15px;">
+ <li class="active pagination-label"><a>Annotations par page : </a></li>
+ <li class="{% if page_obj.paginator.per_page == 5 %}active{% endif %}">
+ <a href="?q={{ query }}&perpage=5">5</a>
+ </li>
+ <li class="{% if page_obj.paginator.per_page == 10 %}active{% endif %}">
+ <a href="?q={{ query }}&perpage=10">10</a>
+ </li>
+ <li class="{% if page_obj.paginator.per_page == 25 %}active{% endif %}">
+ <a href="?q={{ query }}&perpage=25">25</a>
+ </li>
+ <li class="{% if page_obj.paginator.per_page == 100 %}active{% endif %}">
+ <a href="?q={{ query }}&perpage=100">100</a>
+ </li>
+ </ul>
+ {% if page_obj.has_previous or page_obj.has_next %}
+ <ul class="pagination pull-right items-pagination">
+ {% if page_obj.has_previous %}
+ <li>
+ <a href="?page={{page_obj.previous_page_number}}&perpage={{page_obj.paginator.per_page}}" aria-label="Précédent">
+ <span aria-hidden="true">«</span>
+ </a>
+ </li>
+ {% endif %}
+
+ {% for page in page_obj.paginator.page_range %}
+ <li id="page-link-{{page}}" class="pagination-link {% if page == page_obj.number %}active{% endif %}">
+ <a {% if page != page_obj.number %}href="?q={{query}}&page={{page}}&perpage={{page_obj.paginator.per_page}}"{% endif %}>{{page}}</a>
+ </li>
+ {% endfor %}
+
+ {% if page_obj.has_next %}
+ <li>
+ <a href="?page={{page_obj.next_page_number}}&perpage={{page_obj.paginator.per_page}}" aria-label="Précédent">
+ <span aria-hidden="true">»</span>
+ </a>
+ </li>
+ {% endif %}
+ </ul>
+ {% endif %}
</form>
{% endblock %}
\ No newline at end of file
--- a/src/iconolab/templates/search/default_search.html Tue Oct 11 12:18:52 2016 +0200
+++ b/src/iconolab/templates/search/default_search.html Wed Oct 12 13:30:13 2016 +0200
@@ -7,7 +7,7 @@
<h2>Recherche</h2>
- <form method="get" action=".">
+ <form method="get" action="{% url 'search_indexes:haystack_search' %}">
<table>
<tr>
--- a/src/iconolab/templates/search/image_search.html Tue Oct 11 12:18:52 2016 +0200
+++ b/src/iconolab/templates/search/image_search.html Wed Oct 12 13:30:13 2016 +0200
@@ -7,7 +7,7 @@
<h2>Recherche</h2>
- <form method="get" action=".">
+ <form method="get" action="{% url 'search_indexes:haystack_search' %}">
<table>
<tr>
@@ -18,33 +18,135 @@
</td>
</tr>
</table>
-
- <h3><strong>{{ page_obj.paginator.count }}</strong> image(s)</h3>
-
- {% for result in page_obj.object_list %}
-
- {% thumbnail result.object.media "400x400" crop=False as im %}
- <div class="annotation-item result" style="position:relative;">
- <a href="{% url 'item_detail' result.object.collection result.object.item.item_guid %}">
- <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
- </a>
+ </form>
+ <h3><strong>{{ page_obj.paginator.count }}</strong> image(s)</h3>
+ <div class="row">
+ <div id="list-items" class="col-md-12">
+ <ul class="search-image-list-wrapper list-unstyled">
+ {% for item in page_obj.object_list %}
+ <li class="search-image-list-li container panel panel-default col-md-12">
+ <div class="search-image-container row search-image-list-image-container" >
+ {% if item.object.images.count > 1 %}
+ {% with item.object.images.first as main_image %}
+ {% if main_image.height > main_image.width %}
+ <div class="pull-left search-item-links text-center col-md-4" 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.object.collection.name item.object.item_guid %}?show={{secondary_image.image_guid}}">
+ <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
+ </a>
+ </div>
+ {% endthumbnail %}
+ <div class="secondary-images" style="display:inline-block">
+ {% for secondary_image in item.object.images.all %}
+ {% if secondary_image != main_image and forloop.counter <= 4 %}
+ {% thumbnail secondary_image.media "165x90" crop=False as im %}
+ <div class="secondary-image">
+ <a href="{% url 'item_detail' item.object.collection.name item.object.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="search-item-links pull-left col-md-4" style="display:inline-block; margin: 10px 0px;">
+ {% thumbnail main_image.media "350x150" crop=False as im %}
+ <div>
+ <a href="{% url 'item_detail' item.object.collection.name item.object.item_guid %}">
+ <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
+ </a>
+ </div>
+ {% endthumbnail %}
+ <div class="secondary-images pull-left" style="display:inline-block; margin-top:5px;">
+ {% for secondary_image in item.object.images.all %}
+ {% if secondary_image != main_image and forloop.counter <= 4 %}
+ {% thumbnail secondary_image.media "110x140" crop=False as im %}
+ <div class="secondary-image">
+ <a href="{% url 'item_detail' item.object.collection.name item.object.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 "350x300" crop=False as im %}
+ <a href="{% url 'item_detail' 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 class="search-item-info text-left col-md-8" style="display:inline-block; margin: 10px 0px;">
+ <div class="object-infos">
+ <a class="btn btn-default btn-xs pull-right collection-home-item-btn" href="{% url 'item_detail' item.object.collection.name item.object.item_guid %}"><i class="fa fa-eye"></i> Détail de l'objet</a>
+ </div>
+ <h1><small>Métadonnées de l'objet</small></h1>
+ {% if item.object.metadatas.designation %}<h3>Désignation : <small>{{item.object.metadatas.designation}}</small></h3>{% endif %}
+ {% if item.object.metadatas.authors %}<h4>Auteur(s) : <small>{{item.object.metadatas.designation}}</small></h4>{% endif %}
+ {% if item.object.metadatas.conservation_location %}<h4>Conservé à : <small>{{item.object.metadatas.conservation_location}}</small></h4>{% endif %}
+ {% if item.object.metadatas.datation %}<h4>Datation : <small>{{item.object.metadatas.datation}}</small></h4>{% endif %}
+ {% if item.object.metadatas.technics %}<h5>Techniques : <small>{{item.object.metadatas.technics}}</small></h5>{% endif %}
+ {% if item.object.metadatas.measurements %}<h5>Mesures : {{item.object.metadatas.measurements}}</h5>{% endif %}
+ {% if item.object.metadatas.create_or_usage_location %}<h5>Lieu de création/utilisation : <small>{{item.object.metadatas.create_or_usage_location}}</small></h5>{% endif %}
+ {% if item.object.metadatas.discovery_context %}<h5>Contexte de découverte : <small>{{item.object.metadatas.discovery_context}}</small></h5>{% endif %}
+ {% if item.object.metadatas.photo_credits %}<h5>Crédits photographiques : <small>{{item.object.metadatas.photo_credits}}</small></h5>{% endif %}
+ {% if item.object.metadatas.inventory_number %}<h5>Numéro d'inventaire : <small>{{item.object.metadatas.inventory_number}}</small></h5>{% endif %}
</div>
- {% endthumbnail %}
-
- <p>
- <a href="{% url 'item_detail' result.object.collection result.object.item.item_guid %}">{{ result.object.title }}</a>
- <span>collection {{result.object.collection}}</span>
- </p>
- {% empty %}
- <p>Aucune image n'a été trouvée.</p>
- {% endfor %}
-
- {% if page_obj.has_previous or page_obj.has_next %}
- <div>
- {% if page_obj.has_previous %}<a href="?q={{ query }}&page={{ page_obj.previous_page_number }}">{% endif %}« Previous{% if page_obj.has_previous %}</a>{% endif %}
- |
- {% if page_obj.has_next %}<a href="?q={{ query }}&page={{ page_obj.next_page_number }}">{% endif %}Next »{% if page_obj.has_next %}</a>{% endif %}
- </div>
- {% endif %}
- </form>
+ </div>
+ </li>
+ {% endfor %}
+ </ul>
+ <ul class="pagination pull-right items-perpage" style="margin-left: 15px;">
+ <li class="active pagination-label"><a>Objets par page : </a></li>
+ <li class="{% if page_obj.paginator.per_page == 5 %}active{% endif %}">
+ <a href="?q={{ query }}&perpage=5">5</a>
+ </li>
+ <li class="{% if page_obj.paginator.per_page == 10 %}active{% endif %}">
+ <a href="?q={{ query }}&perpage=10">10</a>
+ </li>
+ <li class="{% if page_obj.paginator.per_page == 25 %}active{% endif %}">
+ <a href="?q={{ query }}&perpage=25">25</a>
+ </li>
+ <li class="{% if page_obj.paginator.per_page == 100 %}active{% endif %}">
+ <a href="?q={{ query }}&perpage=100">100</a>
+ </li>
+ </ul>
+ {% if page_obj.has_previous or page_obj.has_next %}
+ <ul class="pagination pull-right items-pagination">
+ {% if page_obj.has_previous %}
+ <li>
+ <a href="?page={{page_obj.previous_page_number}}&perpage={{page_obj.paginator.per_page}}" aria-label="Précédent">
+ <span aria-hidden="true">«</span>
+ </a>
+ </li>
+ {% endif %}
+
+ {% for page in page_obj.paginator.page_range %}
+ <li id="page-link-{{page}}" class="pagination-link {% if page == page_obj.number %}active{% endif %}">
+ <a {% if page != page_obj.number %}href="?q={{query}}&page={{page}}&perpage={{page_obj.paginator.per_page}}"{% endif %}>{{page}}</a>
+ </li>
+ {% endfor %}
+
+ {% if page_obj.has_next %}
+ <li>
+ <a href="?page={{page_obj.next_page_number}}&perpage={{page_obj.paginator.per_page}}" aria-label="Précédent">
+ <span aria-hidden="true">»</span>
+ </a>
+ </li>
+ {% endif %}
+ </ul>
+ {% endif %}
+ </div>
+ </div>
{% endblock %}
\ No newline at end of file
--- a/src/iconolab/templates/search/indexes/iconolab/annotation_text.txt Tue Oct 11 12:18:52 2016 +0200
+++ b/src/iconolab/templates/search/indexes/iconolab/annotation_text.txt Wed Oct 12 13:30:13 2016 +0200
@@ -1,5 +1,3 @@
{{ object.current_revision.title }}
-
{{ object.current_revision.description }}
-
{{ object.tag_labels }}
--- a/src/iconolab/templates/search/indexes/iconolab/image_text.txt Tue Oct 11 12:18:52 2016 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-{{ object.school }}
-{{ object.authors }}
-{{ object.designation }}
-{{ object.datation }}
-{{ object.technics }}
-{{ object.measurements }}
-
-{{ object.item.metadatas.create_or_usage_location }}
-{{ object.item.metadatas.discovery_context }}
-{{ object.item.metadatas.conservation_location }}
-
-{{ object.tag_labels }}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/iconolab/templates/search/indexes/iconolab/item_text.txt Wed Oct 12 13:30:13 2016 +0200
@@ -0,0 +1,9 @@
+{{ object.metadatas.school }}
+{{ object.metadatas.authors }}
+{{ object.metadatas.designation }}
+{{ object.metadatas.datation }}
+{{ object.metadatas.technics }}
+{{ object.metadatas.measurements }}
+{{ object.metadatas.create_or_usage_location }}
+{{ object.metadatas.discovery_context }}
+{{ object.metadatas.conservation_location }}
\ No newline at end of file
--- a/src/iconolab/views/iconolab_objects.py Tue Oct 11 12:18:52 2016 +0200
+++ b/src/iconolab/views/iconolab_objects.py Wed Oct 12 13:30:13 2016 +0200
@@ -252,7 +252,7 @@
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))
+ image_guid_to_display = request.GET.get("show", 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