aboutsummaryrefslogtreecommitdiff
path: root/views.py
diff options
context:
space:
mode:
authorAlban Gruin2017-02-06 18:56:28 +0100
committerAlban Gruin2017-02-06 18:56:28 +0100
commit421748e13e41dc24a6dd53ef9e440278c1625957 (patch)
tree577e45f24884dfa4156e418585119aa82c9997a9 /views.py
parent56edcf086a2020cc6ad934d472b9edde1f7650a5 (diff)
Ne retourne pas de 404 si le token n'existe pas
Diffstat (limited to 'views.py')
-rw-r--r--views.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/views.py b/views.py
index 473b319..a7898c2 100644
--- a/views.py
+++ b/views.py
@@ -83,12 +83,14 @@ def confirm_subscription(request, token):
return redirect("timetable", timetable_slug=subscription.group.timetable.slug, group_slug=subscription.group.slug, year=year, week=week)
def cancel_subscription(request, token):
- subscription = get_object_or_404(Subscription, token=token)
- group = subscription.group
- subscription.delete()
+ subscription = Subscription.objects.filter(token=token).first()
+
+ if subscription is not None:
+ group = subscription.group
+ subscription.delete()
- template = loader.get_template("mail/mail_unsubscribed.txt")
- context = Context({"group": group})
- send_mail("Confirmation de la désinscription", template.render(context), settings.DEFAULT_FROM_EMAIL, [subscription.email])
+ template = loader.get_template("mail/mail_unsubscribed.txt")
+ context = Context({"group": group})
+ send_mail("Confirmation de la désinscription", template.render(context), settings.DEFAULT_FROM_EMAIL, [subscription.email])
return redirect("index")