Skip to content

Commit

Permalink
return a result from the logic function
Browse files Browse the repository at this point in the history
  • Loading branch information
Nigel Babu committed Jan 10, 2014
1 parent 1b61c68 commit f275374
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ckan/controllers/user.py
Expand Up @@ -210,14 +210,14 @@ def cycle_apikey(self, id):
data_dict = {'id': id}

try:
get_action('user_cycle_apikey')(context, data_dict)
result = get_action('user_cycle_apikey')(context, data_dict)
except NotAuthorized:
abort(401, _('Unauthorized to edit user %s') % '')
except NotFound:
abort(404, _('User not found'))

h.flash_success(_('Profile updated'))
h.redirect_to(controller='user', action='read', id=data_dict['name'])
h.redirect_to(controller='user', action='read', id=result['name'])

def _save_new(self, context):
try:
Expand Down
2 changes: 1 addition & 1 deletion ckan/logic/action/update.py
Expand Up @@ -695,7 +695,7 @@ def user_cycle_apikey(context, data_dict):
old_data = _get_action('user_show')(context, data_dict)
old_data['apikey'] = model.types.make_uuid()
data_dict = old_data
_get_action('user_update')(context, data_dict)
return _get_action('user_update')(context, data_dict)


def task_status_update(context, data_dict):
Expand Down
3 changes: 2 additions & 1 deletion ckan/new_tests/logic/action/test_update.py
Expand Up @@ -85,10 +85,11 @@ def test_user_cycle_apikey(self):
user = factories.User()
# Required because you can only cycle your own API key
context = {'user': user['name']}
helpers.call_action('user_cycle_apikey', context=context, id=user['name'])
result = helpers.call_action('user_cycle_apikey', context=context, id=user['name'])
updated_user = helpers.call_action('user_show', context=context, id=user['id'])

assert updated_user['apikey'] != user['apikey']
assert result['apikey'] == updated_user['apikey']

def test_user_update_with_id_that_does_not_exist(self):
user_dict = factories.User.attributes()
Expand Down

0 comments on commit f275374

Please sign in to comment.