aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--templates/mail_confirm.txt9
-rw-r--r--views.py7
2 files changed, 16 insertions, 0 deletions
diff --git a/templates/mail_confirm.txt b/templates/mail_confirm.txt
new file mode 100644
index 0000000..3ceb4cf
--- /dev/null
+++ b/templates/mail_confirm.txt
@@ -0,0 +1,9 @@
+Vous avez été inscrit sur l'emploi du temps {{ group.timetable.name }} - {{ group.name }}
+
+Si pour valider l'abonnement, suivez ce lien : {% url "confirm" token %}
+
+Si vous pensez que vous avez été inscrit par erreur, suivez ce lien : {% url "cancel" token %}
+
+Vous ne recevrez aucun mail tant que vous n'avez pas validé votre abonnement.
+
+{% include "mail_footer.txt" %}
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()