Commits

rmoch committed 652bc2a

unsubscription page redirection, and move NOTIFICATION_REGISTRATION_MESSAGE_TAG to project settings

  • Participants
  • Parent commits 44c4de6

Comments (0)

Files changed (2)

File notification/templates/notification/edit_notification.html

 
 {{ form.errors }}
 
-<div class="">
+<div id="edit-notification">
 
-<form method="POST" action="">{% csrf_token %}
+<form method="POST" action="." id="notification)form">{% csrf_token %}
 
 <table>
 {{ form.as_table }}
 <tr><td></td><td><button name="submit" type="submit" value="send">Save &amp; send</button></tr>
 <tr><td></td><td><button name="submit" type="submit" value="save">Save</button></tr>
 </table>
+
 </form>
+
 </div>
 
 {% endblock %}

File notification/views.py

 # -*- coding: utf-8 -*-
 
-from django.shortcuts import redirect, render, get_object_or_404
+from django.conf import settings
 from django.contrib.auth.decorators import login_required
 from django.contrib import messages
 from django.http import Http404
 #from django.core.urlresolvers import reverse
+from django.shortcuts import redirect, render, get_object_or_404
 from django.utils.translation import ugettext as _
 from django.views.decorators.http import require_POST
 
 from .forms import SimpleRegistrationForm, NotificationForm
 from .models import Notification, SimpleRegistration
 
-NOTIFICATION_REGISTRATION_MESSAGE_TAG = 'notification'
 
 @require_POST
 def register(request):
     if form.is_valid():
         if form.save():
             messages.add_message(request, messages.INFO, _(u"Votre inscription a bien été enregistrée"),
-                    extra_tags=NOTIFICATION_REGISTRATION_MESSAGE_TAG)
+                    extra_tags=settings.NOTIFICATION_REGISTRATION_MESSAGE_TAG)
         else:
             messages.add_message(request, messages.WARNING, _(u"Vous êtes déjà abonné"),
-                    extra_tags=NOTIFICATION_REGISTRATION_MESSAGE_TAG)
+                    extra_tags=settings.NOTIFICATION_REGISTRATION_MESSAGE_TAG)
     else:
         messages.add_message(request, messages.ERROR, _(u"Cette adresse email n’est pas valide"),
-                    extra_tags=NOTIFICATION_REGISTRATION_MESSAGE_TAG)
+                    extra_tags=settings.NOTIFICATION_REGISTRATION_MESSAGE_TAG)
     return redirect(request.POST.get('next') or '/')
 
 
         simple_registration.unregistred = True
         simple_registration.save()
         messages.add_message(request, messages.INFO, _(u"Vous avez bien été désinscrit"),
-                extra_tags=NOTIFICATION_REGISTRATION_MESSAGE_TAG)
+                extra_tags=settings.NOTIFICATION_REGISTRATION_MESSAGE_TAG)
     except SimpleRegistration.DoesNotExist:
         pass
-    return redirect('/')    # TODO add a setting for the unregister redirection
+    return redirect(settings.NOTIFICATION_UNSUBSCRIBE_REDIRECT or '/')    # TODO add a setting for the unregister redirection
 
 
 @login_required