aboutsummaryrefslogtreecommitdiff
path: root/views.py
diff options
context:
space:
mode:
authorAlban Gruin2017-01-25 13:55:29 +0100
committerAlban Gruin2017-01-25 13:55:29 +0100
commita98fcce79627994f397d457677082b9c5e1b6192 (patch)
tree5c9e7210b88b215f57847312a832b24cbd4b2692 /views.py
parentafc9f62cc44c6f6a05e46b46ce53a3c49e7ead6e (diff)
Ajout d'un mail de confirmation d'inscription
Diffstat (limited to 'views.py')
-rw-r--r--views.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/views.py b/views.py
index 40c08b9..b4518f3 100644
--- a/views.py
+++ b/views.py
@@ -2,6 +2,9 @@ from django.http import HttpResponse, Http404
from django.db.models import Count
from django.shortcuts import get_object_or_404, redirect, render
from django.utils import timezone
+from django.core.mail import send_mail
+from django.conf import settings
+from django.template import Context, loader
from edt.forms import SubscribeForm
from edt.models import Timetable, LastUpdate, Group, Subscription, Course
@@ -52,6 +55,10 @@ def subscribe(request, timetable_slug, year, week, group_slug):
subscription = Subscription(email=request.POST["email"], group=group)
subscription.save()
+ template = loader.get_template("mail_confirm.txt")
+ context = Context({"group": group, "admins": settings.ADMINS, "token": subscription.token})
+ send_mail("Confirmation de l'abonnemenent", template.render(context), settings.DEFAULT_FROM_EMAIL, [request.POST["email"]])
+
return redirect("timetable", timetable_slug=timetable_slug, year=year, week=int(week), group_slug=group_slug)
else:
form = SubscribeForm()