Mercurial > public > sg101
comparison accounts/views.py @ 679:89b240fe9297
For Django 1.5.2: import json; django.utils.simplejson is deprecated.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 15 Aug 2013 20:14:33 -0500 |
parents | 8e6b8ffe5f34 |
children | 988782c6ce6c |
comparison
equal
deleted
inserted
replaced
678:38a198ea8c61 | 679:89b240fe9297 |
---|---|
1 """ | 1 """ |
2 Views for the accounts application. | 2 Views for the accounts application. |
3 | 3 |
4 """ | 4 """ |
5 import datetime | 5 import datetime |
6 import json | |
6 import logging | 7 import logging |
7 | 8 |
8 from django.shortcuts import render | 9 from django.shortcuts import render |
9 from django.template import RequestContext | 10 from django.template import RequestContext |
10 from django.template.loader import render_to_string | 11 from django.template.loader import render_to_string |
11 from django.http import HttpResponse, HttpResponseRedirect | 12 from django.http import HttpResponse, HttpResponseRedirect |
12 from django.core.urlresolvers import reverse | 13 from django.core.urlresolvers import reverse |
13 from django.conf import settings | 14 from django.conf import settings |
14 from django.contrib.auth.forms import AuthenticationForm | 15 from django.contrib.auth.forms import AuthenticationForm |
15 from django.contrib.auth import login | 16 from django.contrib.auth import login |
16 from django.utils import simplejson | |
17 | 17 |
18 from accounts.models import PendingUser | 18 from accounts.models import PendingUser |
19 from accounts.forms import RegisterForm, ForgotUsernameForm | 19 from accounts.forms import RegisterForm, ForgotUsernameForm |
20 from accounts import create_new_user | 20 from accounts import create_new_user |
21 from antispam.decorators import rate_limit | 21 from antispam.decorators import rate_limit |
103 response['navbar_html'] = render_to_string('navbar.html', | 103 response['navbar_html'] = render_to_string('navbar.html', |
104 {'user': request.user}, RequestContext(request)) | 104 {'user': request.user}, RequestContext(request)) |
105 else: | 105 else: |
106 response['error'] = 'Invalid username or password' | 106 response['error'] = 'Invalid username or password' |
107 | 107 |
108 return HttpResponse(simplejson.dumps(response), | 108 return HttpResponse(json.dumps(response), content_type='application/json') |
109 content_type='application/json') | |
110 | 109 |
111 ####################################################################### | 110 ####################################################################### |
112 | 111 |
113 def username_query(request): | 112 def username_query(request): |
114 """This view handles forgotten username queries.""" | 113 """This view handles forgotten username queries.""" |