diff core/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 1982996ce365
children e932f2ecd4a7
line wrap: on
line diff
--- a/core/views.py	Wed Aug 14 14:53:21 2013 -0500
+++ b/core/views.py	Thu Aug 15 20:14:33 2013 -0500
@@ -1,14 +1,16 @@
 """
 Views for the core application. These are mainly shared, common views
 used by multiple applications.
+
 """
+import json
+
 from django.contrib.auth.models import User
 from django.http import HttpResponse
 from django.shortcuts import render_to_response
 from django.contrib.auth.decorators import login_required
 from django.views.decorators.http import require_GET
 from django.views.generic import TemplateView
-import django.utils.simplejson as json
 
 
 @login_required
@@ -17,23 +19,25 @@
     """
     This view provides the Markdown help cheat sheet. It is expected
     to be called via AJAX.
+
     """
     return render_to_response('core/markdown_help.html')
 
 
 def ajax_users(request):
     """
-    If the user is authenticated, return a JSON array of strings of usernames 
-    whose names start with the 'q' GET parameter, limited by the 'limit' GET 
+    If the user is authenticated, return a JSON array of strings of usernames
+    whose names start with the 'q' GET parameter, limited by the 'limit' GET
     parameter. Only active usernames are returned.
     If the user is not authenticated, return an empty array.
+
     """
     q = request.GET.get('q', None)
     if q is None or not request.user.is_authenticated():
         return HttpResponse(json.dumps([]), content_type='application/json')
 
     limit = int(request.GET.get('limit', 10))
-    users = User.objects.filter(is_active=True, 
+    users = User.objects.filter(is_active=True,
             username__istartswith=q).values_list('username', flat=True)[:limit]
     return HttpResponse(json.dumps(list(users)), content_type='application/json')