Add page with list of revisions.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/iconolab/templates/iconolab/annotation_revisions.html Fri Apr 28 11:29:47 2017 +0200
@@ -0,0 +1,48 @@
+{% extends 'iconolab_base.html' %}
+
+{% load staticfiles %}
+{% load thumbnail %}
+{% load iconolab_tags %}
+{% load humanize %}
+
+{% block content %}
+<table class="table">
+ <thead>
+ <th></th>
+ <th>Auteur</th>
+ <th>Titre</th>
+ <th>Description</th>
+ <th>Mots-clé</th>
+ <th></th>
+ </thead>
+ <tbody>
+ {% for revision in revisions %}
+ <tr>
+ <td>
+ <div class="fragment-container" style="position: relative">
+ {% thumbnail revision.annotation.image.media "100x100" crop=False 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="{{ revision.fragment|clean_path }}" opacity="0.7" fill="orange"></path>
+ </g>
+ </svg>
+ {% endthumbnail %}
+ </div>
+ </td>
+ <td>{{ revision.author }}</td>
+ <td>{{ revision.title }}</td>
+ <td>{{ revision.description }}</td>
+ <td>
+ {% for tagging_info in revision.tagginginfo_set.all %}
+ <p>
+ <span class="label label-default"><i class="fa fa-tag"></i> {{ tagging_info.tag.label }}</span>
+ </p>
+ {% endfor %}
+ </td>
+ <td class="text-right">{{ revision.created|date:"d/m/Y H:i" }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+</table>
+{% endblock %}
--- a/src/iconolab/templates/iconolab/detail_image.html Fri Apr 28 11:17:15 2017 +0200
+++ b/src/iconolab/templates/iconolab/detail_image.html Fri Apr 28 11:29:47 2017 +0200
@@ -55,7 +55,9 @@
<div class="panel-body">
<annotation-form v-bind:annotation="annotation"
v-bind:is-authenticated="isAuthenticated"
- action="{% url 'annotation_edit' collection_name image_guid ':annotation_guid' %}">
+ action="{% url 'annotation_edit' collection_name image_guid ':annotation_guid' %}"
+ revisions-url="{% url 'annotation_revisions' collection_name image_guid ':annotation_guid' %}"
+ author-url="{% url 'user_home' '--username--' %}">
{% csrf_token %}
</annotation-form>
<div class="annotation-comment-box" id="form-comment">
--- a/src/iconolab/urls.py Fri Apr 28 11:17:15 2017 +0200
+++ b/src/iconolab/urls.py Fri Apr 28 11:29:47 2017 +0200
@@ -42,7 +42,7 @@
url(r'^collections/(?P<collection_name>[a-z0-9\-]+)/images/(?P<image_guid>[^/]+)/annotations/(?P<annotation_guid>[^/]+)/detail$', views.objects.ShowAnnotationViewOld.as_view(), name='annotation_detail_old'),
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/?$', views.objects.ShowRevisionsView.as_view(), name='annotation_revisions'),
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'),
url(r'^collections/(?P<collection_name>[a-z0-9\-]+)/images/(?P<image_guid>[^/]+)/annotations/(?P<annotation_guid>[^/]+)/revisions/(?P<revision_guid>[^/]+)/merge$', login_required(views.objects.MergeProposalView.as_view()), name='annotation_merge'),
--- a/src/iconolab/views/objects.py Fri Apr 28 11:17:15 2017 +0200
+++ b/src/iconolab/views/objects.py Fri Apr 28 11:29:47 2017 +0200
@@ -546,6 +546,29 @@
annotation.stats.save()
return render(request, 'iconolab/detail_annotation.html', context)
+class ShowRevisionsView(View, ContextMixin, IconolabObjectView):
+ def get_context_data(self, **kwargs):
+ context = super(ShowRevisionsView, 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['revisions'] = AnnotationRevision.objects.filter(annotation=annotation).order_by('-created')
+
+ return render(request, 'iconolab/annotation_revisions.html', context)
class ReadonlyAnnotationView(View, ContextMixin, IconolabObjectView):
"""
--- a/src_js/iconolab-bundle/src/components/editor/AnnotationForm.vue Fri Apr 28 11:17:15 2017 +0200
+++ b/src_js/iconolab-bundle/src/components/editor/AnnotationForm.vue Fri Apr 28 11:29:47 2017 +0200
@@ -34,7 +34,11 @@
@change="onTagsChange($event.tags)"></tag-list>
<input type="hidden" name="tags" v-model="serializedTags">
</div>
- <p class="small text-center text-muted" v-show="readonly">{{ lastRevisionText }}</p>
+ <p class="small text-center text-muted" v-show="annotation">
+ <a v-bind:href="revisionsUrlComputed">Dernière version</a>
+ <span>{{ dateComputed }} par</span>
+ <a v-bind:href="authorUrlComputed">{{ annotation.author }}</a>
+ </p>
<button type="submit" v-if="annotation && !readonly" v-bind:class="{ disabled: !hasChanged }"
class="btn btn-block btn-sm btn-primary">Enregistrer une nouvelle version</button>
</form>
@@ -70,7 +74,9 @@
isAuthenticated: {
type: Boolean,
default: false
- }
+ },
+ revisionsUrl: String,
+ authorUrl: String
},
components: {
'tag-list': TagList
@@ -102,6 +108,21 @@
return 'Dernière version ' + date.fromNow() + ' par ' + this.annotation.author;
}
},
+ revisionsUrlComputed: function() {
+ if (this.annotation) {
+ return this.revisionsUrl.replace(':annotation_guid', this.annotation.annotation_guid);
+ }
+ },
+ authorUrlComputed: function() {
+ if (this.annotation) {
+ return this.authorUrl.replace('--username--', this.annotation.author);
+ }
+ },
+ dateComputed: function() {
+ if (this.annotation) {
+ return moment(this.annotation.created).locale('fr').fromNow();
+ }
+ },
formAction: function() {
if (this.annotation) {
return this.action.replace(':annotation_guid', this.annotation.annotation_guid);