project/kiwipycon/user/views.py
changeset 96 3ece0de11641
parent 94 e86755df35da
child 101 fb27be005a5c
--- a/project/kiwipycon/user/views.py	Tue May 11 03:47:41 2010 +0530
+++ b/project/kiwipycon/user/views.py	Tue May 11 03:48:47 2010 +0530
@@ -3,25 +3,21 @@
 
 #python
 from urlparse import urlparse
-import json
-import urllib
 import os
 
 #django
 from django.conf import settings
-from django.db.models import Q
-from django.http import HttpResponse
-from django.shortcuts import render_to_response
-from django.template import RequestContext
-from django.core.urlresolvers import reverse
-from django.db.models.signals import post_save
-
-#django.contrib
 from django.contrib.auth.decorators import login_required
 from django.contrib.auth.forms import AuthenticationForm
 from django.contrib.auth.forms import PasswordChangeForm
 from django.contrib.auth.models import User
 from django.core.exceptions import ObjectDoesNotExist
+from django.core.urlresolvers import reverse
+from django.db.models import Q
+from django.http import HttpResponse
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+from django.utils import simplejson as json
 
 #PIL
 from PIL import Image
@@ -32,7 +28,6 @@
 from project.kiwipycon.registration.models import Registration
 from project.kiwipycon.registration.models import Wifi
 from project.kiwipycon.registration.forms import WifiForm
-from project.kiwipycon.sponsor.models import Sponsor
 
 from .utils import kiwipycon_createuser
 from .utils import handle_uploaded_photo
@@ -62,8 +57,6 @@
     else:
         photo = '/img/user-default.png'
 
-    qstring = ""
-
     wifi_comment = None
     if wifiobj:
         wifi_form = False
@@ -248,31 +241,25 @@
     """
 
     get_params = request.GET
-    authors_str = get_params.get('input')
+    search_author = get_params.get('q')
 
-    if not authors_str:
+    if search_author:
+        search_author = search_author.strip()
+    else:
         return HttpResponse(json.dumps(''))
-
-    authors = authors_str.split(',')
-    search_author = authors[-1].strip()
+    
 
     users = User.objects.filter(
         Q(username__istartswith=search_author) | Q(
         first_name__istartswith=search_author) | Q(
         last_name__istartswith=search_author))
 
-    results = [{'id': '',
-                'info': 'plugin_header',
-                'value': 'User Names'
-              }]
+    results = []
     
     for user in users:
         results.append(
-            {'id': 'author_name',
-             'info': str(user.get_full_name()),
-             'value': str(user.username)
+            {'name': str(user.username),
+             'value': '%s (%s)' % (user.get_full_name(), user.username)
             })
 
-    json_response = {'results': results}
-
-    return HttpResponse(json.dumps(json_response))
\ No newline at end of file
+    return HttpResponse(json.dumps(results))