From f27537477309ae7ef90f06dd42a62ca280350b71 Mon Sep 17 00:00:00 2001 From: Nigel Babu Date: Fri, 10 Jan 2014 12:51:05 +0530 Subject: [PATCH] return a result from the logic function --- ckan/controllers/user.py | 4 ++-- ckan/logic/action/update.py | 2 +- ckan/new_tests/logic/action/test_update.py | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ckan/controllers/user.py b/ckan/controllers/user.py index 2aec7b1d05a..bd145a1a606 100644 --- a/ckan/controllers/user.py +++ b/ckan/controllers/user.py @@ -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: diff --git a/ckan/logic/action/update.py b/ckan/logic/action/update.py index 207d3cdd52c..3fbe7806cab 100644 --- a/ckan/logic/action/update.py +++ b/ckan/logic/action/update.py @@ -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): diff --git a/ckan/new_tests/logic/action/test_update.py b/ckan/new_tests/logic/action/test_update.py index 08c88ed9820..ec8ff202acd 100644 --- a/ckan/new_tests/logic/action/test_update.py +++ b/ckan/new_tests/logic/action/test_update.py @@ -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()