From ae96cf86c7d1c0870c37fbaaf79444fc146bd3a3 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 24 Dec 2010 15:44:13 +0530 Subject: [PATCH] error strings, sort api in docs --- pandora/user/views.py | 17 +++++++++-------- static/js/pandora.api.js | 8 ++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/pandora/user/views.py b/pandora/user/views.py index 23b39ef9f..9cab7b6ed 100644 --- a/pandora/user/views.py +++ b/pandora/user/views.py @@ -35,7 +35,7 @@ def api_login(request): status: {'code': int, 'text': string} data: { errors: { - username: 'Unknown User', + username: 'Unknown Username', password: 'Incorrect Password' } user: { @@ -50,7 +50,7 @@ def api_login(request): if models.User.objects.filter(username=form.data['username']).count() == 0: response = json_response({ 'errors': { - 'username': 'Unknown User' + 'username': 'Unknown Username' } }) else: @@ -88,8 +88,9 @@ def api_logout(request): status: {'code': int, 'text': string} } ''' - response = json_response(text='logged out') + response = json_response(text='ok') if request.user.is_authenticated(): + response = json_response(text='logged out') logout(request) return render_to_json_response(response) actions.register(api_logout, 'logout') @@ -111,7 +112,7 @@ def register(request): status: {'code': int, 'text': string} data: { errors: { - username: 'Unknown User', + username: 'Unknown Username', password: 'Incorrect Password' } user: { @@ -126,13 +127,13 @@ def register(request): if models.User.objects.filter(username=form.data['username']).count() > 0: response = json_response({ 'errors': { - 'username': 'Username taken' + 'username': 'Username already exists' } }) elif models.User.objects.filter(email=form.data['email']).count() > 0: response = json_response({ 'errors': { - 'email': 'Email is used by another account' + 'email': 'Email address already exits' } }) else: @@ -168,7 +169,7 @@ def api_recover(request): status: {'code': int, 'text': string} data: { errors: { - username_or_email: 'Username or email not found' + username_or_email: 'Username or email address not found' } } } @@ -203,7 +204,7 @@ def api_recover(request): else: response = json_response({ 'errors': { - 'username_or_email': 'Username or email not found' + 'username_or_email': 'Username or email address not found' } }) else: diff --git a/static/js/pandora.api.js b/static/js/pandora.api.js index 93b2ae6b9..6272518a0 100755 --- a/static/js/pandora.api.js +++ b/static/js/pandora.api.js @@ -60,16 +60,16 @@ function constructList() { id: 'actionList', request: function(data, callback) { if(!data.keys) { - app.api.apidoc(function(results) { + app.api.api(function(results) { var items = []; - $.each(results.data.actions, function(k) {items.push({'name': k})}); + $.each(results.data.actions, function(i, k) {items.push({'name': k})}); var result = {'data': {'items': items.length}}; callback(result); }); } else { - app.api.apidoc(function(results) { + app.api.api(function(results) { var items = []; - $.each(results.data.actions, function(k) {items.push({'name': k})}); + $.each(results.data.actions, function(i, k) {items.push({'name': k})}); var result = {'data': {'items': items}}; callback(result); });