Allow editing/commenting only for authenticated users.
--- a/src/iconolab/templates/iconolab/detail_image.html Fri Feb 24 14:54:06 2017 +0100
+++ b/src/iconolab/templates/iconolab/detail_image.html Fri Feb 24 15:15:27 2017 +0100
@@ -80,12 +80,14 @@
var currentPath = "{{ request.path }}";
var getCommentFormURL = "{% url 'get_comment_form' ':annotation_guid' %}"
+ var isAuthenticated = {% if user.is_authenticated %}true{% else %}false{% endif %};
var vm = new Vue({
el: '.annotation-navigator',
data: function() {
return {
- annotation: null
+ annotation: null,
+ isAuthenticated: isAuthenticated
};
}
});
@@ -109,7 +111,9 @@
$('.list-group a[data-annotation-id]').removeClass('active');
$el.addClass('active');
- $('#form-comment form').replaceWith(form).show();
+ if (isAuthenticated) {
+ $('#form-comment form').replaceWith(form).show();
+ }
vm.annotation = annotations[revision];
--- a/src_js/iconolab-bundle/src/components/editor/AnnotationForm.vue Fri Feb 24 14:54:06 2017 +0100
+++ b/src_js/iconolab-bundle/src/components/editor/AnnotationForm.vue Fri Feb 24 15:15:27 2017 +0100
@@ -1,6 +1,6 @@
<template>
<div>
- <button v-if="annotation" @click="readonly = !readonly"
+ <button v-if="annotation && isAuthenticated" @click="readonly = !readonly"
class="btn btn-xs pull-right"
v-bind:class="{ 'btn-primary': readonly, 'btn-warning': !readonly }">
<i class="fa fa-edit" v-if="readonly"></i>
@@ -62,6 +62,10 @@
return null;
}
},
+ isAuthenticated: {
+ type: Boolean,
+ default: false
+ }
},
components: {
'tag-list': TagList
--- a/src_js/iconolab-bundle/src/components/editor/Canvas.vue Fri Feb 24 14:54:06 2017 +0100
+++ b/src_js/iconolab-bundle/src/components/editor/Canvas.vue Fri Feb 24 15:15:27 2017 +0100
@@ -81,6 +81,10 @@
type: Boolean,
default: false
},
+ isAuthenticated: {
+ type: Boolean,
+ default: false
+ }
},
components: {
shapeRect: ShapeRect,
@@ -158,7 +162,7 @@
},
annotation: function(annotation) {
this.reset();
- this.readonly = !!annotation;
+ this.readonly = !!annotation || !this.isAuthenticated;
if (this.annotation) {
this.loadAnnotation();
}
@@ -397,6 +401,8 @@
handleDrawFree: function() {
+ if (this.readonly) { return; }
+
this.removeEventHandlers();
var clickTimeout;
@@ -421,6 +427,8 @@
handleDrawRect: function() {
+ if (this.readonly) { return; }
+
this.removeEventHandlers();
var startPosition = { x: 0, y: 0 };