# HG changeset patch # User Alexandre Segura # Date 1493371787 -7200 # Node ID b71475c271597e2bb6378503a5531c1c6a91cfca # Parent ca1c0a625d705a8d0c59d579c4e90e6935c475fb Add page with list of revisions. diff -r ca1c0a625d70 -r b71475c27159 src/iconolab/templates/iconolab/annotation_revisions.html --- /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 %} + + + + + + + + + + + {% for revision in revisions %} + + + + + + + + + {% endfor %} + +
AuteurTitreDescriptionMots-clé
+
+ {% thumbnail revision.annotation.image.media "100x100" crop=False as im %} + + + + + + + {% endthumbnail %} +
+
{{ revision.author }}{{ revision.title }}{{ revision.description }} + {% for tagging_info in revision.tagginginfo_set.all %} +

+  {{ tagging_info.tag.label }} +

+ {% endfor %} +
{{ revision.created|date:"d/m/Y H:i" }}
+{% endblock %} diff -r ca1c0a625d70 -r b71475c27159 src/iconolab/templates/iconolab/detail_image.html --- 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 @@
+ 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 %}
diff -r ca1c0a625d70 -r b71475c27159 src/iconolab/urls.py --- 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[a-z0-9\-]+)/images/(?P[^/]+)/annotations/(?P[^/]+)/detail$', views.objects.ShowAnnotationViewOld.as_view(), name='annotation_detail_old'), url(r'^collections/(?P[a-z0-9\-]+)/images/(?P[^/]+)/annotations/(?P[^/]+)/readonly$', views.objects.ReadonlyAnnotationView.as_view(), name='annotation_readonly'), url(r'^collections/(?P[a-z0-9\-]+)/images/(?P[^/]+)/annotations/(?P[^/]+)/edit$', login_required(views.objects.EditAnnotationView.as_view()), name='annotation_edit'), - url(r'^collections/(?P[a-z0-9\-]+)/images/(?P[^/]+)/annotations/(?P[^/]+)/revisions/?$', django_views.generic.RedirectView.as_view(pattern_name="annotation_detail")), + url(r'^collections/(?P[a-z0-9\-]+)/images/(?P[^/]+)/annotations/(?P[^/]+)/revisions/?$', views.objects.ShowRevisionsView.as_view(), name='annotation_revisions'), url(r'^collections/(?P[a-z0-9\-]+)/images/(?P[^/]+)/annotations/(?P[^/]+)/revisions/(?P[^/]+)/detail', views.objects.ShowRevisionView.as_view(), name='revision_detail'), url(r'^collections/(?P[a-z0-9\-]+)/images/(?P[^/]+)/annotations/(?P[^/]+)/revisions/(?P[^/]+)/merge$', login_required(views.objects.MergeProposalView.as_view()), name='annotation_merge'), diff -r ca1c0a625d70 -r b71475c27159 src/iconolab/views/objects.py --- 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): """ diff -r ca1c0a625d70 -r b71475c27159 src_js/iconolab-bundle/src/components/editor/AnnotationForm.vue --- 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)">
-

{{ lastRevisionText }}

+

+ Dernière version + {{ dateComputed }} par + {{ annotation.author }} +

@@ -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);