Skip to content

Commit

Permalink
Change wording to generate instead of cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
Nigel Babu committed Jan 28, 2014
1 parent 77d1bfb commit f645f8a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ckan/config/routing.py
Expand Up @@ -349,7 +349,7 @@ def make_map():
m.connect('/user/edit', action='edit')
# Note: openid users have slashes in their ids, so need the wildcard
# in the route.
m.connect('user_cycle_apikey', '/user/cycle_key/{id}', action='cycle_apikey')
m.connect('user_generate_apikey', '/user/generate_key/{id}', action='generate_apikey')
m.connect('/user/activity/{id}/{offset}', action='activity')
m.connect('user_activity_stream', '/user/activity/{id}',
action='activity', ckan_icon='time')
Expand Down
4 changes: 2 additions & 2 deletions ckan/controllers/user.py
Expand Up @@ -195,7 +195,7 @@ def delete(self, id):
msg = _('Unauthorized to delete user with id "{user_id}".')
abort(401, msg.format(user_id=id))

def cycle_apikey(self, id):
def generate_apikey(self, id):
'''Cycle the API key of a user'''
context = {'model': model,
'session': model.Session,
Expand All @@ -210,7 +210,7 @@ def cycle_apikey(self, id):
data_dict = {'id': id}

try:
result = get_action('user_cycle_apikey')(context, data_dict)
result = get_action('user_generate_apikey')(context, data_dict)
except NotAuthorized:
abort(401, _('Unauthorized to edit user %s') % '')
except NotFound:
Expand Down
6 changes: 3 additions & 3 deletions ckan/logic/action/update.py
Expand Up @@ -665,7 +665,7 @@ def user_update(context, data_dict):
return model_dictize.user_dictize(user, context)


def user_cycle_apikey(context, data_dict):
def user_generate_apikey(context, data_dict):
'''Cycle a user's API key
:param id: the name or id of the user whose key needs to be updated
Expand All @@ -677,7 +677,7 @@ def user_cycle_apikey(context, data_dict):
model = context['model']
user = context['user']
session = context['session']
schema = context.get('schema') or schema_.default_cycle_apikey_user_schema()
schema = context.get('schema') or schema_.default_generate_apikey_user_schema()
context['schema'] = schema
# check if user id in data_dict
id = _get_or_bust(data_dict, 'id')
Expand All @@ -689,7 +689,7 @@ def user_cycle_apikey(context, data_dict):
raise NotFound('User was not found.')

# check permission
_check_access('user_cycle_apikey', context, data_dict)
_check_access('user_generate_apikey', context, data_dict)

# change key
old_data = _get_action('user_show')(context, data_dict)
Expand Down
2 changes: 1 addition & 1 deletion ckan/logic/auth/update.py
Expand Up @@ -212,7 +212,7 @@ def user_update(context, data_dict):
(user, user_obj.id)}


def user_cycle_apikey(context, data_dict):
def user_generate_apikey(context, data_dict):
user = context['user']
user_obj = logic_auth.get_user_object(context, data_dict)
if user == user_obj.name:
Expand Down
2 changes: 1 addition & 1 deletion ckan/logic/schema.py
Expand Up @@ -438,7 +438,7 @@ def default_update_user_schema():

return schema

def default_cycle_apikey_user_schema():
def default_generate_apikey_user_schema():
schema = default_update_user_schema()

schema['apikey'] = [not_empty, unicode]
Expand Down
4 changes: 2 additions & 2 deletions ckan/new_tests/logic/action/test_update.py
Expand Up @@ -79,13 +79,13 @@ def test_user_update_name(self):

## END-BEFORE

def test_user_cycle_apikey(self):
def test_user_generate_apikey(self):
'''Test that updating a user's name works successfully.'''

user = factories.User()
# Required because you can only cycle your own API key
context = {'user': user['name']}
result = helpers.call_action('user_cycle_apikey', context=context,
result = helpers.call_action('user_generate_apikey', context=context,
id=user['name'])
updated_user = helpers.call_action('user_show', context=context,
id=user['id'])
Expand Down
4 changes: 2 additions & 2 deletions ckan/templates/user/edit_user_form.html
Expand Up @@ -38,9 +38,9 @@
{% endif %}
{% endblock %}
{% block generate_button %}
{% if h.check_access('user_cycle_apikey', {'id': data.id}) %}
{% if h.check_access('user_generate_apikey', {'id': data.id}) %}
{% set locale = h.dump_json({'content': _('Are you sure you want to regenerate the API key?')}) %}
<a class="btn btn-warning" href="{% url_for controller='user', action='cycle_apikey', id=data.id %}" data-module="confirm-action" data-module-i18n="{{ locale }}">{% block generate_button_text %}{{ _('Regenerate API Key') }}{% endblock %}</a>
<a class="btn btn-warning" href="{% url_for controller='user', action='generate_apikey', id=data.id %}" data-module="confirm-action" data-module-i18n="{{ locale }}">{% block generate_button_text %}{{ _('Regenerate API Key') }}{% endblock %}</a>
{% endif %}
{% endblock %}
{{ form.required_message() }}
Expand Down

0 comments on commit f645f8a

Please sign in to comment.