# HG changeset patch # User Alexandre Segura # Date 1489495298 -3600 # Node ID 2a9ce7ec3a294665405a521d0fd879f574263042 # Parent 5bda901efcf6292f783e8959105b84523474fdaa Display date & author of last revision. diff -r 5bda901efcf6 -r 2a9ce7ec3a29 src/iconolab/serializers.py --- a/src/iconolab/serializers.py Tue Mar 14 13:30:45 2017 +0100 +++ b/src/iconolab/serializers.py Tue Mar 14 13:41:38 2017 +0100 @@ -10,6 +10,7 @@ tags = serializers.SerializerMethodField('get_normalized_tags') annotation_guid = serializers.SerializerMethodField() stats = AnnotationStatsSerializer(source='annotation.stats') + author = serializers.SerializerMethodField() def get_normalized_tags(self, obj): tags = [] @@ -25,9 +26,12 @@ def get_annotation_guid(self, obj): return obj.annotation.annotation_guid + def get_author(self, obj): + return obj.author.username + class Meta: model = AnnotationRevision - fields = ('annotation_guid', 'title', 'description', 'fragment', 'tags', 'stats') + fields = ('annotation_guid', 'title', 'description', 'fragment', 'tags', 'stats', 'created', 'author') class IconolabCommentSerializer(serializers.ModelSerializer): allow_thread = serializers.BooleanField() diff -r 5bda901efcf6 -r 2a9ce7ec3a29 src_js/iconolab-bundle/src/components/editor/AnnotationForm.vue --- a/src_js/iconolab-bundle/src/components/editor/AnnotationForm.vue Tue Mar 14 13:30:45 2017 +0100 +++ b/src_js/iconolab-bundle/src/components/editor/AnnotationForm.vue Tue Mar 14 13:41:38 2017 +0100 @@ -34,6 +34,7 @@ @change="onTagsChange($event.tags)"> +

{{ lastRevisionText }}

@@ -45,6 +46,7 @@ import TagList from '../tagform/TagList.vue' import _ from 'lodash' import showdown from 'showdown' + import moment from 'moment' const converter = new showdown.Converter() @@ -91,9 +93,15 @@ } }, computed: { - descriptionComputed: function(){ + descriptionComputed: function() { return converter.makeHtml(this.description); }, + lastRevisionText: function() { + if (this.annotation) { + var date = moment(this.annotation.created).locale('fr'); + return 'Dernière version ' + date.fromNow() + ' par ' + this.annotation.author; + } + }, formAction: function() { if (this.annotation) { return this.action.replace(':annotation_guid', this.annotation.annotation_guid);