This commit is contained in:
j 2010-07-22 15:03:16 +02:00
parent 4c63da2c0a
commit 7e789242a1
2 changed files with 19 additions and 1 deletions

View file

@ -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

View file

@ -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: