Added a readonly view for annotation detail that doesn't display comments and edit links + added a link to that view from the admin interface
authordurandn
Mon, 12 Dec 2016 17:27:33 +0100
changeset 282 7204cfdde3be
parent 281 0a0b82040ee1
child 283 d8fcfac848ed
Added a readonly view for annotation detail that doesn't display comments and edit links + added a link to that view from the admin interface
src/iconolab/templates/iconolab/detail_annotation_readonly.html
src/iconolab/templates/partials/image_annotations_list.html
src/iconolab/urls.py
src/iconolab/views/objects.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/iconolab/templates/iconolab/detail_annotation_readonly.html	Mon Dec 12 17:27:33 2016 +0100
@@ -0,0 +1,99 @@
+{% extends 'iconolab_base.html' %}
+
+{% load i18n %}
+{% load staticfiles %}
+{% load thumbnail %}
+{% load iconolab_tags %}
+
+{% block content %}
+  <div id="annotation-wrapper" class="row" style="border: 1px solid gray;padding-top: 10px;">
+    
+    <div id="detail-annotation" class="col-md-12">
+      <div v-show="!showZoom" class="col-md-6">
+        <div class="small-image-wrapper" style="position: relative">
+          {% thumbnail annotation.image.media "300x300" crop=False as im %}
+            <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="{{ annotation.current_revision.fragment|clean_path }}" opacity="0.7" fill="orange"></path>
+              </g>
+
+            </svg>
+            
+          {% endthumbnail %}
+        </div>
+            <br>
+          <p class="btn btn-default btn-sm" @click="toggleZoomView" style="padding-top:2px"><i class="fa fa-search-plus showPointer"></i></p>
+            <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> Voir l'objet de cette annotation</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-md-6' style="">
+            <h4>Annotation créée par <a href="{% url 'user_home' annotation.author.id %}">{{ annotation.author.username }}</a></h4>    
+          <p><strong>Titre :</strong> {{ annotation.current_revision.title }}</p>
+          <p><strong>Description :</strong> {{ annotation.current_revision.description }}</p>
+            {% if tags_data != "[]" %}
+              <p><strong>Mot-clés :</strong></p>
+              <typeahead :read-only="1" :tags="{{ tags_data }}"></typeahead>
+              <br>
+            {% endif %}
+            <br>
+            {% include "partials/annotation_stats_panel.html" with annotation=annotation label="Statistiques sur cette annotation:" %}  
+        </div>
+        <!-- zoomView -->
+        <div class="col-md-12 zoom-view" style="display:none" v-show="showZoom">
+          <div class="col-md-12 no-padding"><p @click="toggleZoomView" class="btn btn-link pull-right"><i class="fa fa-close"></i></i> Fermer</p></div>
+          <div class="col-md-2">
+            {% thumbnail annotation.image.media "100x100" crop=False as im %}
+            <zoomview ref="zoomview" main-image-id="main-image" zoomtarget="zoomTarget" :image-url="'{{ im.url }}'" :image-width="{{ im.width }}" :image-height="{{ im.height }}"></zoomview>
+            {% endthumbnail %}
+          </div>
+          <div class="col-md-10 zoomTarget-wrapper">
+            {% with image.media as im %}
+              <svg id="zoomTarget" ref="zoomTarget" width="920" height="920"> 
+                <image id="main-image" class="main-image" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="{{ im.url }}" x="0" y="0" width="{{ im.width }}" height="{{ im.height }}"></image>
+                <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>
+            {% endwith %}
+            </div>
+          </div>
+
+    </div>
+  </div>
+{% endblock %}
+
+{% block footer_js %}
+  <script>
+    new Vue({
+      el: "#detail-annotation",
+      
+      data: {
+        showZoom: false
+      },
+
+      methods: {
+        
+        toggleZoomView: function () {
+          if (this.showZoom) {
+            this.showZoom = false;
+          }
+
+          else {
+            this.showZoom = true;
+          }
+        },
+
+
+      },
+
+      components: {
+        'Typeahead': iconolab.VueComponents.Typeahead,
+        'Zoomview': iconolab.VueComponents.Zoomview
+      }
+    });
+  </script>
+{% endblock %}
\ No newline at end of file
--- a/src/iconolab/templates/partials/image_annotations_list.html	Mon Dec 12 15:02:31 2016 +0100
+++ b/src/iconolab/templates/partials/image_annotations_list.html	Mon Dec 12 17:27:33 2016 +0100
@@ -59,8 +59,10 @@
             <td class="col-md-3">
               <b>Espace de travail</b><br>
               <a class="btn btn-primary btn-sm" href="{% url 'annotation_detail' annotation.image.item.collection.name annotation.image.image_guid annotation.annotation_guid %}" target="_blank">Suivre le lien</a><br>
-              <br><b>Etat courant<br>
+              <br><b>Permalien vers l'état actuel</b><br>
               <a class="btn btn-primary btn-sm" href="{% url 'revision_detail' annotation.image.item.collection.name annotation.image.image_guid annotation.annotation_guid annotation.current_revision.revision_guid %}" target="_blank">Suivre le lien</a><br>
+              <br><b>Permalien vers l'état dynamique</b><br>
+              <a class="btn btn-primary btn-sm" href="{% url 'annotation_readonly' annotation.image.item.collection.name annotation.image.image_guid annotation.annotation_guid %}" target="_blank">Suivre le lien</a><br>
             </td>
             {% endif %}
           </tr>
--- a/src/iconolab/urls.py	Mon Dec 12 15:02:31 2016 +0100
+++ b/src/iconolab/urls.py	Mon Dec 12 17:27:33 2016 +0100
@@ -38,6 +38,7 @@
     url(r'^collections/(?P<collection_name>[a-z0-9\-]+)/images/(?P<image_guid>[^/]+)/annotations/?$', django_views.generic.RedirectView.as_view(pattern_name="image_detail")),
     url(r'^collections/(?P<collection_name>[a-z0-9\-]+)/images/(?P<image_guid>[^/]+)/annotations/create$', login_required(views.objects.CreateAnnotationView.as_view()), name='annotation_create'),
     url(r'^collections/(?P<collection_name>[a-z0-9\-]+)/images/(?P<image_guid>[^/]+)/annotations/(?P<annotation_guid>[^/]+)/detail$', views.objects.ShowAnnotationView.as_view(), name='annotation_detail'),
+    url(r'^collections/(?P<collection_name>[a-z0-9\-]+)/images/(?P<image_guid>[^/]+)/annotations/(?P<annotation_guid>[^/]+)/readonly$', views.objects.ReadonlyAnnotationView.as_view(), name='annotation_readonly'),
     url(r'^collections/(?P<collection_name>[a-z0-9\-]+)/images/(?P<image_guid>[^/]+)/annotations/(?P<annotation_guid>[^/]+)/edit$', login_required(views.objects.EditAnnotationView.as_view()), name='annotation_edit'),
     url(r'^collections/(?P<collection_name>[a-z0-9\-]+)/images/(?P<image_guid>[^/]+)/annotations/(?P<annotation_guid>[^/]+)/revisions/?$', django_views.generic.RedirectView.as_view(pattern_name="annotation_detail")),
     url(r'^collections/(?P<collection_name>[a-z0-9\-]+)/images/(?P<image_guid>[^/]+)/annotations/(?P<annotation_guid>[^/]+)/revisions/(?P<revision_guid>[^/]+)/detail', views.objects.ShowRevisionView.as_view(), name='revision_detail'),
--- a/src/iconolab/views/objects.py	Mon Dec 12 15:02:31 2016 +0100
+++ b/src/iconolab/views/objects.py	Mon Dec 12 17:27:33 2016 +0100
@@ -401,6 +401,34 @@
         annotation.stats.save()
         return render(request, 'iconolab/detail_annotation.html', context)
 
+
+class ReadonlyAnnotationView(View, ContextMixin, IconolabObjectView):
+
+    def get_context_data(self, **kwargs):
+        context = super(ReadonlyAnnotationView, self).get_context_data(**kwargs)
+        context['collection_name'] = self.kwargs.get('collection_name', '')
+        context['image_guid'] = self.kwargs.get('image_guid', '')
+        context['annotation_guid'] = self.kwargs.get('annotation_guid', '')
+        return context
+
+    def get(self, request, *args, **kwargs):
+        success, result = self.check_kwargs(kwargs)
+        if success:
+            (collection, image, annotation,) = result
+        else:
+            return result(request)
+        context = self.get_context_data(**kwargs)
+        context['collection'] = collection
+        context['image'] = image
+        context['annotation'] = annotation
+        context['tags_data'] = annotation.current_revision.get_tags_json()
+
+        image.stats.views_count += 1
+        image.stats.save()
+        annotation.stats.views_count += 1
+        annotation.stats.save()
+        return render(request, 'iconolab/detail_annotation_readonly.html', context)
+
 class EditAnnotationView(View, ContextMixin, IconolabObjectView):
 
     def get_context_data(self, **kwargs):