diff options
author | Madhusudan.C.S | 2010-04-01 11:59:35 +0530 |
---|---|---|
committer | Madhusudan.C.S | 2010-04-01 11:59:35 +0530 |
commit | f245bcffa2d4bd4efc6ab934db85eb76626ec599 (patch) | |
tree | 4c91dd755d542e7e0bc9e3154f93990410617e45 /project/kiwipycon/user/views.py | |
parent | 93ab9caaffc346dfceb70648cd4bbaea7eb266ac (diff) | |
download | scipycon-f245bcffa2d4bd4efc6ab934db85eb76626ec599.tar.gz scipycon-f245bcffa2d4bd4efc6ab934db85eb76626ec599.tar.bz2 scipycon-f245bcffa2d4bd4efc6ab934db85eb76626ec599.zip |
Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Diffstat (limited to 'project/kiwipycon/user/views.py')
-rw-r--r-- | project/kiwipycon/user/views.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/project/kiwipycon/user/views.py b/project/kiwipycon/user/views.py index e9a0454..8b890c1 100644 --- a/project/kiwipycon/user/views.py +++ b/project/kiwipycon/user/views.py @@ -1,12 +1,16 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import + #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 @@ -16,6 +20,7 @@ from django.db.models.signals import post_save 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 #PIL @@ -236,3 +241,38 @@ def username(request, template_name="user/username.html"): "form": username_form })) + +def get_usernames(request): + """Returns in json the list of ten possible usernames + starting with the last pattern in the comma separated string + """ + + get_params = request.GET + authors_str = get_params.get('input') + + if not authors_str: + 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' + }] + + for user in users: + results.append( + {'id': 'author_name', + 'info': str(user.get_full_name()), + 'value': str(user.username) + }) + + json_response = {'results': results} + + return HttpResponse(json.dumps(json_response))
\ No newline at end of file |