Display message when revision needs approval.
authorAlexandre Segura <mex.zktk@gmail.com>
Wed, 12 Apr 2017 19:41:01 +0200
changeset 461 4701ee4556e3
parent 460 5fe876675e24
child 462 0572214c8546
Display message when revision needs approval.
src/iconolab/templates/iconolab/detail_image.html
src/iconolab/views/objects.py
--- a/src/iconolab/templates/iconolab/detail_image.html	Wed Apr 12 19:20:16 2017 +0200
+++ b/src/iconolab/templates/iconolab/detail_image.html	Wed Apr 12 19:41:01 2017 +0200
@@ -6,6 +6,15 @@
 
 {% block content_fluid %}
 
+{% if messages %}
+  {% for message in messages %}
+  <div class="alert alert-info alert-dismissible" role="alert">
+    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+    {{ message }}
+  </div>
+  {% endfor %}
+{% endif %}
+
 <div class="annotation-navigator">
   <div class="annotation-navigator-list">
     <div class="panel panel-default">
--- a/src/iconolab/views/objects.py	Wed Apr 12 19:20:16 2017 +0200
+++ b/src/iconolab/views/objects.py	Wed Apr 12 19:41:01 2017 +0200
@@ -3,6 +3,7 @@
 from django.db.models import Count
 from django.contrib.auth.decorators import login_required
 from django.contrib.auth.models import User
+from django.contrib import messages
 from django.views.generic import View, DetailView, RedirectView, TemplateView
 from django.views.generic.base import ContextMixin
 from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
@@ -604,6 +605,10 @@
             revision_fragment = annotation_form.cleaned_data['fragment']
             revision_tags_json = annotation_form.cleaned_data['tags']
             new_revision = annotation.make_new_revision(revision_author, revision_title, revision_description, revision_fragment, revision_tags_json)
+
+            if (annotation.author != revision_author):
+                messages.add_message(request, messages.INFO, "Votre modification a été prise en compte. Le creéateur de l'annotation a été notifié.")
+
             redirect_url = reverse('image_detail', kwargs={'collection_name': collection_name, 'image_guid': image_guid})
             return redirect(redirect_url + '#' + str(annotation.annotation_guid))
         context = self.get_context_data(**kwargs)