Mercurial > public > sg101
diff gpp/messages/views.py @ 149:ab7830b067b3
Implement ticket #40. Added a simple way to search for usernames and then view their profile. Moved this ajax username search feature out of the messages app and into core.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 14 Dec 2009 05:07:28 +0000 |
parents | dbd703f7d63a |
children | 7ad1f3e77cd9 |
line wrap: on
line diff
--- a/gpp/messages/views.py Sun Dec 13 21:57:34 2009 +0000 +++ b/gpp/messages/views.py Mon Dec 14 05:07:28 2009 +0000 @@ -3,11 +3,7 @@ import datetime from django.shortcuts import render_to_response from django.template import RequestContext -from django.contrib.auth.models import User from django.http import HttpResponseRedirect -from django.http import HttpResponse -from django.http import HttpResponseBadRequest -from django.http import HttpResponseForbidden from django.contrib.auth.decorators import login_required from django.shortcuts import get_object_or_404 from django.core.urlresolvers import reverse @@ -285,26 +281,3 @@ }, context_instance = RequestContext(request)) - -def ajax_users(request): - """ - If the user is authenticated, return a string of usernames whose names start with - the 'q' GET parameter, limited by the 'limit' GET parameters. The names are separated - by newlines. - If the user is not authenticated, return an empty string. - This is used by the auto-complete function in the compose form. - """ - q = request.GET.get('q', None) - if q is None: - return HttpResponseBadRequest() - - if request.user.is_authenticated(): - q = request.GET.get('q', ' ') - limit = int(request.GET.get('limit', 10)) - users = User.objects.filter(username__istartswith=q).values_list('username', flat=True)[:limit] - user_list = u"\n".join(users) - return HttpResponse(user_list) - return HttpResponseForbidden() - - -# vim: ts=4 sw=4