blob: 4e023867ef90447baee1dc27baf0d22f315504bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# Patchwork - automated patch tracking system
# Copyright (C) 2008 Jeremy Kerr <jk@ozlabs.org>
# Copyright (C) 2016 Stephen Finucane <stephenfinucane@hotmail.com>
#
# SPDX-License-Identifier: GPL-2.0-or-later
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.shortcuts import render
from patchwork.models import EmailConfirmation
from patchwork.views import mail
from patchwork.views import user
def confirm(request, key):
views = {
'userperson': user.link_confirm,
'registration': user.register_confirm,
'optout': mail.optout_confirm,
'optin': mail.optin_confirm,
}
conf = get_object_or_404(EmailConfirmation, key=key)
if conf.type not in views:
raise Http404
if conf.active and conf.is_valid():
return views[conf.type](request, conf)
context = {}
context['conf'] = conf
if not conf.active:
context['error'] = 'inactive'
elif not conf.is_valid():
context['error'] = 'expired'
return render(request, 'patchwork/confirm-error.html', context)
|