Work on item model + item view to show items with multiple images instead of image detail + fix thumbnails in templates
--- a/src/iconolab/models.py Mon Jul 11 14:51:49 2016 +0200
+++ b/src/iconolab/models.py Wed Jul 13 17:45:17 2016 +0200
@@ -36,11 +36,12 @@
class Item(models.Model):
collection = models.ForeignKey(Collection, related_name="items")
+ item_guid = models.UUIDField(default=uuid.uuid4, editable=False)
class ItemMetadata(models.Model):
item = models.OneToOneField('Item', related_name='metadatas')
- joconde_ref = models.CharField(max_length=20, null=False, blank=False, unique=True)
+ joconde_ref = models.CharField(max_length=20)
domain = models.CharField(max_length=255)
title = models.CharField(max_length=255)
description = models.CharField(max_length=255)
--- a/src/iconolab/templates/iconolab/change_annotation.html Mon Jul 11 14:51:49 2016 +0200
+++ b/src/iconolab/templates/iconolab/change_annotation.html Wed Jul 13 17:45:17 2016 +0200
@@ -6,7 +6,7 @@
{% block content %}
- <div id="drawing-zone" class="row" style="padding-top: 10px; border:1px solid orange">
+ <div id="drawing-zone" class="row" style="padding-top: 10px; padding-bottom: 10px; border:1px solid orange">
<div v-show='!formView' style="display:none" class="editor-wrapper col-md-12">
<div class='col-md-2'>
<ul class="form-drawing-wrapper list-inline">
@@ -15,7 +15,7 @@
<li @click="setDrawingMode('FREE')" v-bind:class="{ 'selected': !isRect }" class='pull-md-right drawingModeBtn'>Libre</li>
</ul>
- {% thumbnail image.media "x100" crop="center" as im %}
+ {% thumbnail image.media "100x100" crop=False as im %}
<zoomview ref="zoomview" :image-url="'{{ im.url }}'" :width="{{ im.width }}" :height="{{ im.height }}">
</zoomview>
{% endthumbnail %}
--- a/src/iconolab/templates/iconolab/collection_home.html Mon Jul 11 14:51:49 2016 +0200
+++ b/src/iconolab/templates/iconolab/collection_home.html Wed Jul 13 17:45:17 2016 +0200
@@ -17,14 +17,16 @@
<li class="small-image-wrapper">
<div class="fragment-container" style="position: relative">
- {% for image in item.images.all %}
- {% thumbnail image.media "x500" crop="center" as im %}
- <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
+ {% with item.images.first as image %}
+ {% thumbnail image.media "300x300" crop=False as im %}
+ <a href="{% url 'item_detail' collection_name item.item_guid %}">
+ <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
+ </a>
{% endthumbnail %}
<div class="fragment-infos">
- <a class="fa fa-eye" href="{% url 'image_detail' collection_name image.image_guid %}">Voir les annotations</a>
+ <a class="fa fa-eye" href="{% url 'item_detail' collection_name item.item_guid %}"> Détail de l'objet</a>
</div>
- {% endfor %}
+ {% endwith %}
</li>
{% endfor %}
</ul>
--- a/src/iconolab/templates/iconolab/detail_annotation.html Mon Jul 11 14:51:49 2016 +0200
+++ b/src/iconolab/templates/iconolab/detail_annotation.html Wed Jul 13 17:45:17 2016 +0200
@@ -28,6 +28,11 @@
{% endthumbnail %}
</div>
<p @click="toggleZoomView" style="padding-top:2px"><i class="fa fa-search-plus showPointer"></i></p>
+
+ <br>
+ <a class="btn btn-default btn-sm" href="{% url 'item_detail' collection_name image.item.item_guid %}"><i class="fa fa-eye" aria-hidden="true"></i> Revoir l'objet</a>
+ <a class="btn btn-default btn-sm" href="{% url 'image_detail' collection_name image_guid %}"><i class="fa fa-picture-o" aria-hidden="true"></i> Voir les annotations sur l'image</a>
+
</div>
<div v-show="!showZoom" id="detail-annotation" class='col-xs-6' style="">
--- a/src/iconolab/templates/partials/image_annotations_list.html Mon Jul 11 14:51:49 2016 +0200
+++ b/src/iconolab/templates/partials/image_annotations_list.html Wed Jul 13 17:45:17 2016 +0200
@@ -3,33 +3,46 @@
<ul class="annotation-list-wrapper list-inline">
- <h4><strong>Annotations de l'image</strong></h4>
-
+ <h4><strong>Annotations de l'image</strong></h4>
{% if not annotation_list %}
<p> Aucune annotation pour cette image </p>
{% else %}
- {% for annotation in annotation_list %}
- <li class="small-image-wrapper">
- <div class="fragment-container" style="position: relative">
- {% thumbnail annotation.image.media "x300" crop="center" as im %}
- <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="{{ annotation.current_revision.fragment|clean_path }}" opacity="0.7" fill="orange"></path>
- </g>
- </svg>
- </div>
- {% endthumbnail %}
- <div class="fragment-infos">
- <a class="fa fa-eye" href="{% url 'annotation_detail' collection_name image_guid annotation.annotation_guid %}">Voir</a>
- <p class="small">Créee par <strong>{{ annotation.author }}</strong>, dernière révision le {{ annotation.current_revision.created|date:'d-m-Y' }}<p>
- <p class="small">Contributeurs:
- {% for contributor in annotation.stats.contributors %}
- <strong>{{ contributor }}</strong>{% if not forloop.last %}, {% endif %}
- {% endfor %}
- </p>
- </div>
- </li>
- {% endfor %}
+ <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>
+ </thead>
+ {% for annotation in annotation_list %}
+ <tr>
+ <td>
+ <div class="fragment-container" style="position: relative">
+ {% thumbnail annotation.image.media "150x150" crop=False as im %}
+ <a href="{% url 'annotation_detail' collection_name image_guid annotation.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="{{ annotation.current_revision.fragment|clean_path }}" opacity="0.7" fill="orange"></path>
+ </g>
+ </svg>
+ </a>
+ {% endthumbnail %}
+ </div>
+ </td>
+ <td>{{ annotation.current_revision.title }}</td>
+ <td>{{ annotation.author }}</td>
+ <td>{{ annotation.created|date:'d-m-Y' }}</td>
+ <td>{{ annotation.current_revision.created|date:'d-m-Y' }}</td>
+ <td>
+ {% for contributor in annotation.stats.contributors %}
+ {{ contributor }}{% if not forloop.last %}, {% endif %}
+ {% endfor %}
+ </td>
+ </tr>
+ {% endfor %}
+ </table>
{% endif %}
</ul>
\ No newline at end of file
--- a/src/iconolab/urls.py Mon Jul 11 14:51:49 2016 +0200
+++ b/src/iconolab/urls.py Wed Jul 13 17:45:17 2016 +0200
@@ -28,6 +28,7 @@
url(r'^admin/', admin.site.urls),
url(r'^home$', views.GlobalHomepageView.as_view(), name="home"),
url(r'^collections/(?P<collection_name>[a-z]+)$', views.CollectionHomepageView.as_view(), name='collection_home'), # Home fond
+ url(r'^collections/(?P<collection_name>[a-z]+)/items/(?P<item_guid>[^/]+)$', views.ShowItemView.as_view(), name='item_detail'),
url(r'^collections/(?P<collection_name>[a-z]+)/images/(?P<image_guid>[^/]+)$', views.ShowImageView.as_view(), name='image_detail'),
url(r'^collections/(?P<collection_name>[a-z]+)/images/(?P<image_guid>[^/]+)/annotations/create$', login_required(views.CreateAnnotationView.as_view()), name='annotation_create'),
url(r'^collections/(?P<collection_name>[a-z]+)/images/(?P<image_guid>[^/]+)/annotations/(?P<annotation_guid>[^/]+)/detail$', views.ShowAnnotationView.as_view(), name='annotation_detail'),
--- a/src/iconolab/views.py Mon Jul 11 14:51:49 2016 +0200
+++ b/src/iconolab/views.py Wed Jul 13 17:45:17 2016 +0200
@@ -11,7 +11,7 @@
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.conf import settings
-from iconolab.models import Annotation, AnnotationRevision, Collection, Image, IconolabComment, MetaCategory, MetaCategoryInfo
+from iconolab.models import Annotation, AnnotationRevision, Collection, Item, Image, IconolabComment, MetaCategory, MetaCategoryInfo
from iconolab.forms.annotations import AnnotationRevisionForm
import datetime
import django_comments
@@ -23,7 +23,7 @@
def get(self, request, *args, **kwargs):
context = {}
context["collections"] = Collection.objects
- return render(request, 'iconolab/home.html', context);
+ return render(request, 'iconolab/home.html', context)
class CollectionHomepageView(View, ContextMixin):
@@ -43,8 +43,35 @@
context = super(CollectionHomepageView, self).get_context_data(**kwargs)
context['collection_name'] = self.kwargs.get('collection_name', '')
context['collection'] = collection
- return render(request, 'iconolab/collection_home.html', context);
+ return render(request, 'iconolab/collection_home.html', context)
+
+
+class ShowItemView(View, ContextMixin):
+
+ def check_kwargs(self, kwargs):
+ try:
+ collection = Collection.objects.prefetch_related("items", "items__images").get(name=kwargs.get('collection_name'))
+ except Collection.DoesNotExist:
+ return False, RedirectView.as_view(url=reverse('404error'))
+ try:
+ item = Item.objects.prefetch_related("images").get(item_guid=kwargs.get('item_guid'))
+ except Item.DoesNotExist:
+ return False, RedirectView.as_view(url=reverse('404error'))
+ return True, (collection, item)
+
+ def get(self, request, *args, **kwargs):
+ success, result = self.check_kwargs(kwargs)
+ if success:
+ (collection, item) = result
+ else:
+ return result(request)
+ context = super(ShowItemView, self).get_context_data(**kwargs)
+ context['collection_name'] = self.kwargs.get('collection_name', '')
+ context['item_guid'] = self.kwargs.get('image_guid', '')
+ context['collection'] = collection
+ context['item'] = item
+ return render(request, 'iconolab/detail_item.html', context);
class ShowImageView(View, ContextMixin):
@@ -70,7 +97,7 @@
context['image_guid'] = self.kwargs.get('image_guid', '')
context['collection'] = collection
context['image'] = image
- return render(request, 'iconolab/detail_image.html', context);
+ return render(request, 'iconolab/detail_image.html', context)
class CreateAnnotationView(View, ContextMixin):