comparison gpp/accounts/views.py @ 316:767cedc7d12a

Fixing #144; integrate with new Django logging support. Also added unit tests for Donations app.
author Brian Neal <bgneal@gmail.com>
date Sun, 30 Jan 2011 20:02:32 +0000
parents 75ea1a8be7f2
children 69d0306a6fe7
comparison
equal deleted inserted replaced
315:36373d995611 316:767cedc7d12a
45 ####################################################################### 45 #######################################################################
46 46
47 def register_confirm(request, username, key): 47 def register_confirm(request, username, key):
48 if request.user.is_authenticated(): 48 if request.user.is_authenticated():
49 return HttpResponseRedirect(settings.LOGIN_REDIRECT_URL) 49 return HttpResponseRedirect(settings.LOGIN_REDIRECT_URL)
50 50
51 # purge expired users 51 # purge expired users
52 52
53 PendingUser.objects.purge_expired() 53 PendingUser.objects.purge_expired()
54 54
55 ip = request.META.get('REMOTE_ADDR', '?') 55 ip = request.META.get('REMOTE_ADDR', '?')
56 try: 56 try:
57 pending_user = PendingUser.objects.get(username = username) 57 pending_user = PendingUser.objects.get(username = username)
58 except PendingUser.DoesNotExist: 58 except PendingUser.DoesNotExist:
59 logging.error('Accounts register_confirm [%s]: user does not exist: %s' % (ip, username)) 59 logging.error('Accounts register_confirm [%s]: user does not exist: %s', ip, username)
60 return render_to_response('accounts/register_failure.html', { 60 return render_to_response('accounts/register_failure.html', {
61 'username': username, 61 'username': username,
62 }, 62 },
63 context_instance = RequestContext(request)) 63 context_instance = RequestContext(request))
64 64
65 if pending_user.key != key: 65 if pending_user.key != key:
66 logging.error('Accounts register_confirm [%s]: key error: %s' % (ip, username)) 66 logging.error('Accounts register_confirm [%s]: key error: %s', ip, username)
67 return render_to_response('accounts/register_failure.html', { 67 return render_to_response('accounts/register_failure.html', {
68 'username': username, 68 'username': username,
69 }, 69 },
70 context_instance = RequestContext(request)) 70 context_instance = RequestContext(request))
71 71
83 new_user.date_joined = new_user.last_login 83 new_user.date_joined = new_user.last_login
84 84
85 new_user.save() 85 new_user.save()
86 pending_user.delete() 86 pending_user.delete()
87 87
88 logging.info('Accounts register_confirm [%s]: success: %s' % (ip, username)) 88 logging.info('Accounts register_confirm [%s]: success: %s', ip, username)
89 return render_to_response('accounts/register_success.html', { 89 return render_to_response('accounts/register_success.html', {
90 'username': username, 90 'username': username,
91 }, 91 },
92 context_instance = RequestContext(request)) 92 context_instance = RequestContext(request))