ソースを参照

Toggle mail notifications

Denis Merigoux 9 年 前
コミット
6db80585c9
共有4 個のファイルを変更した19 個の追加4 個の削除を含む
  1. 7 0
      counter/templates/homeTemplate.html
  2. 2 4
      counter/templates/seumEmail.txt
  3. 2 0
      counter/urls.py
  4. 8 0
      counter/views.py

+ 7 - 0
counter/templates/homeTemplate.html

@@ -145,5 +145,12 @@
145 145
 <div class="row text-center">
146 146
 	<a href="{% url 'logout' %}" class="btn btn-danger">Se déconnecter</a>
147 147
 	<a href="{% url 'password_change' %}" class="btn btn-warning">Changer de mot de passe</a>
148
+	<a href="{% url 'toggle_email_notifications' %}" class="btn btn-info">
149
+		{% if myCounter.email_notifications %}
150
+		Désactiver les notifications par mail
151
+		{% else %}
152
+		Activer les notifications par mail
153
+		{% endif %}
154
+	</a>
148 155
 </div>
149 156
 {% endblock %}

+ 2 - 4
counter/templates/seumEmail.txt

@@ -1,7 +1,5 @@
1
-{% autoescape off %}
2
-{% if selfSeum %}{{name}} a le seum : {{reason}}{% else %}{{who.trigramme}} ({{who.name}}) a foutu le seum à {{name}} : {{reason}}{% endif %}
1
+{% autoescape off %}{% if selfSeum %}{{name}} a le seum : {{reason}}{% else %}{{who.trigramme}} ({{who.name}}) a foutu le seum à {{name}} : {{reason}}{% endif %}
3 2
 --
4 3
 SeumBook™ - http://seum.merigoux.ovh
5 4
 
6
-P.S. : Pour ne plus recevoir ces messages, envoie un mail à denis.merigoux@gmail.com'''
7
-{% endautoescape %}
5
+P.S. : Pour ne plus recevoir ces messages, envoie un mail à denis.merigoux@gmail.com'''{% endautoescape %}

+ 2 - 0
counter/urls.py

@@ -11,6 +11,8 @@ urlpatterns = [
11 11
     url(r'^counter/(?P<id_counter>\d+)/$', views.counter, name="counter"),
12 12
     url(r'^rss/$', SeumFeed()),
13 13
     url(r'^create_user/$', views.createUser, name="create_user"),
14
+    url(r'^toggle-notif/$', views.toggleEmailNotifications,
15
+        name="toggle_email_notifications"),
14 16
     url(r'^login/$', auth_views.login,
15 17
         {'template_name': 'login.html'},
16 18
         name="login"),

+ 8 - 0
counter/views.py

@@ -399,3 +399,11 @@ def createUser(request):
399 399
             return render(request, 'createUserDone.html', {})
400 400
     else:
401 401
         return render(request, 'createUser.html', {'error': None})
402
+
403
+
404
+@login_required
405
+def toggleEmailNotifications(request):
406
+    counter = Counter.objects.get(user=request.user)
407
+    counter.email_notifications = not counter.email_notifications
408
+    counter.save()
409
+    return HttpResponseRedirect(reverse('home'))