diff options
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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() |