comparison accounts/views.py @ 1114:6dd1f0065859

Convert registration views to V3 design.
author Brian Neal <bgneal@gmail.com>
date Tue, 12 Jul 2016 20:44:20 -0500
parents be233ba7ca31
children d613d25a021e
comparison
equal deleted inserted replaced
1113:f27986c11ddf 1114:6dd1f0065859
32 form.save(request) 32 form.save(request)
33 return redirect('accounts-register1') 33 return redirect('accounts-register1')
34 else: 34 else:
35 form = RegisterForm() 35 form = RegisterForm()
36 36
37 return render(request, 'accounts/register.html', {'form': form}) 37 return render(request, 'accounts/register.html', {
38 'form': form,
39 'V3_DESIGN': True,
40 })
38 41
39 ####################################################################### 42 #######################################################################
40 43
41 def register1(request): 44 def register1(request):
42 """Displays the registration code.""" 45 """Displays the registration code."""
43 if request.user.is_authenticated(): 46 if request.user.is_authenticated():
44 return redirect(settings.LOGIN_REDIRECT_URL) 47 return redirect(settings.LOGIN_REDIRECT_URL)
45 48
46 return render(request, 'accounts/register1.html') 49 return render(request, 'accounts/register1.html', {
50 'V3_DESIGN': True,
51 })
47 52
48 ####################################################################### 53 #######################################################################
49 54
50 @log_auth_failures('Register') 55 @log_auth_failures('Register')
51 def register2(request): 56 def register2(request):
61 form.save() 66 form.save()
62 return redirect('accounts-register_thanks') 67 return redirect('accounts-register_thanks')
63 else: 68 else:
64 form = RegisterCodeForm() 69 form = RegisterCodeForm()
65 70
66 return render(request, 'accounts/register2.html', {'form': form}) 71 return render(request, 'accounts/register2.html', {
72 'form': form,
73 'V3_DESIGN': True,
74 })
67 75
68 ####################################################################### 76 #######################################################################
69 77
70 def get_code(request): 78 def get_code(request):
71 code = {'code': 'FAIL-123'} 79 code = {'code': 'FAIL-123'}
79 87
80 def register_thanks(request): 88 def register_thanks(request):
81 if request.user.is_authenticated(): 89 if request.user.is_authenticated():
82 return redirect(settings.LOGIN_REDIRECT_URL) 90 return redirect(settings.LOGIN_REDIRECT_URL)
83 91
84 return render(request, 'accounts/register_thanks.html') 92 return render(request, 'accounts/register_thanks.html', {
93 'V3_DESIGN': True,
94 })
85 95
86 ####################################################################### 96 #######################################################################
87 97
88 def register_confirm(request, username, key): 98 def register_confirm(request, username, key):
89 if request.user.is_authenticated(): 99 if request.user.is_authenticated():
95 105
96 ip = request.META.get('REMOTE_ADDR', '?') 106 ip = request.META.get('REMOTE_ADDR', '?')
97 try: 107 try:
98 pending_user = PendingUser.objects.get(username = username) 108 pending_user = PendingUser.objects.get(username = username)
99 except PendingUser.DoesNotExist: 109 except PendingUser.DoesNotExist:
100 logger.error('Accounts register_confirm [%s]: user does not exist: %s', ip, username) 110 logger.error('Accounts register_confirm [%s]: user does not exist: %s',
101 return render(request, 111 ip, username)
102 'accounts/register_failure.html', 112 return render(request, 'accounts/register_failure.html', {
103 {'username': username}) 113 'username': username,
114 'V3_DESIGN': True,
115 })
104 116
105 if pending_user.key != key: 117 if pending_user.key != key:
106 logger.error('Accounts register_confirm [%s]: key error: %s', ip, username) 118 logger.error('Accounts register_confirm [%s]: key error: %s', ip, username)
107 return render(request, 119 return render(request, 'accounts/register_failure.html', {
108 'accounts/register_failure.html', 120 'username': username,
109 {'username': username}) 121 'V3_DESIGN': True,
122 })
110 123
111 create_new_user(pending_user, ip) 124 create_new_user(pending_user, ip)
112 125
113 return render(request, 126 return render(request, 'accounts/register_success.html', {
114 'accounts/register_success.html', 127 'username': username,
115 {'username': username}) 128 'V3_DESIGN': True,
129 })
116 130
117 ####################################################################### 131 #######################################################################
118 132
119 def username_query(request): 133 def username_query(request):
120 """This view handles forgotten username queries.""" 134 """This view handles forgotten username queries."""