Display date & author of last revision.
--- 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()
--- 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)"></tag-list>
<input type="hidden" name="tags" v-model="serializedTags">
</div>
+ <p class="small text-center text-muted" v-show="readonly">{{ lastRevisionText }}</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>
@@ -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);