From 7e789242a19d0d3e38c8ef009b5b6fe8e9002557 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 22 Jul 2010 15:03:16 +0200 Subject: [PATCH] findUser --- pandora/backend/views.py | 2 +- pandora/oxuser/views.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pandora/backend/views.py b/pandora/backend/views.py index b918c661b..87f762744 100644 --- a/pandora/backend/views.py +++ b/pandora/backend/views.py @@ -32,7 +32,7 @@ import utils import tasks from oxuser.models import getUserJSON -from oxuser.views import api_login, api_logout, api_register, api_contact, api_recover, api_preferences +from oxuser.views import api_login, api_logout, api_register, api_contact, api_recover, api_preferences, api_findUser from archive.views import api_update, api_addArchive, api_editArchive, api_removeArchive from archive.models import File diff --git a/pandora/oxuser/views.py b/pandora/oxuser/views.py index c329c0c8a..a8f78a5fe 100644 --- a/pandora/oxuser/views.py +++ b/pandora/oxuser/views.py @@ -140,6 +140,24 @@ def api_recover(request): response = json_response(status=400, text='invalid data') return render_to_json_response(response) +def api_findUser(request): + ''' + param data + {key: "username", value: "foo", operator: "="} + + return { + 'status': {'code': int, 'text': string} + 'data': { + users = ['user1', 'user2'] + } + } + ''' + #FIXME: support other operators and keys + data = json.loads(request.POST['data']) + response = json_response(status=200, text='ok') + response['data']['users'] = [u.username for u in User.objects.filter(username__iexact=data['value'])] + return render_to_json_response(response) + def recover(request, key): qs = models.UserProfile.objects.filter(recover_key=key) if qs.count() == 1: