# HG changeset patch # User Mads Kiilerich # Date 2015-05-13 01:27:50 # Node ID e3aab61a9411926e3887227eb4c88868b8aa88e2 # Parent 1f2269c26f937bcb45bc26f8b587f3bdf36fe73c spelling: more consistent casing of 'API key' diff --git a/kallithea/controllers/admin/my_account.py b/kallithea/controllers/admin/my_account.py --- a/kallithea/controllers/admin/my_account.py +++ b/kallithea/controllers/admin/my_account.py @@ -251,7 +251,7 @@ class MyAccountController(BaseController description = request.POST.get('description') ApiKeyModel().create(self.authuser.user_id, description, lifetime) Session().commit() - h.flash(_("Api key successfully created"), category='success') + h.flash(_("API key successfully created"), category='success') return redirect(url('my_account_api_keys')) def my_account_api_keys_delete(self): @@ -263,10 +263,10 @@ class MyAccountController(BaseController user.api_key = generate_api_key(user.username) Session().add(user) Session().commit() - h.flash(_("Api key successfully reset"), category='success') + h.flash(_("API key successfully reset"), category='success') elif api_key: ApiKeyModel().delete(api_key, self.authuser.user_id) Session().commit() - h.flash(_("Api key successfully deleted"), category='success') + h.flash(_("API key successfully deleted"), category='success') return redirect(url('my_account_api_keys')) diff --git a/kallithea/controllers/admin/users.py b/kallithea/controllers/admin/users.py --- a/kallithea/controllers/admin/users.py +++ b/kallithea/controllers/admin/users.py @@ -311,7 +311,7 @@ class UsersController(BaseController): description = request.POST.get('description') ApiKeyModel().create(c.user.user_id, description, lifetime) Session().commit() - h.flash(_("Api key successfully created"), category='success') + h.flash(_("API key successfully created"), category='success') return redirect(url('edit_user_api_keys', id=c.user.user_id)) def delete_api_key(self, id): @@ -327,11 +327,11 @@ class UsersController(BaseController): user.api_key = generate_api_key(user.username) Session().add(user) Session().commit() - h.flash(_("Api key successfully reset"), category='success') + h.flash(_("API key successfully reset"), category='success') elif api_key: ApiKeyModel().delete(api_key, c.user.user_id) Session().commit() - h.flash(_("Api key successfully deleted"), category='success') + h.flash(_("API key successfully deleted"), category='success') return redirect(url('edit_user_api_keys', id=c.user.user_id)) diff --git a/kallithea/controllers/api/__init__.py b/kallithea/controllers/api/__init__.py --- a/kallithea/controllers/api/__init__.py +++ b/kallithea/controllers/api/__init__.py @@ -134,7 +134,7 @@ class JSONRPCController(WSGIController): message="JSON parse error ERR:%s RAW:%r" % (e, raw_body)) - # check AUTH based on API KEY + # check AUTH based on API key try: self._req_api_key = json_body['api_key'] self._req_id = json_body['id'] @@ -156,7 +156,7 @@ class JSONRPCController(WSGIController): u = User.get_by_api_key(self._req_api_key) if u is None: return jsonrpc_error(retid=self._req_id, - message='Invalid API KEY') + message='Invalid API key') #check if we are allowed to use this IP auth_u = AuthUser(u.user_id, self._req_api_key, ip_addr=ip_addr) @@ -168,7 +168,7 @@ class JSONRPCController(WSGIController): except Exception, e: return jsonrpc_error(retid=self._req_id, - message='Invalid API KEY') + message='Invalid API key') self._error = None try: @@ -208,7 +208,7 @@ class JSONRPCController(WSGIController): # get our arglist and check if we provided them as args for arg, default in func_kwargs.iteritems(): if arg == USER_SESSION_ATTR: - # USER_SESSION_ATTR is something translated from api key and + # USER_SESSION_ATTR is something translated from API key and # this is checked before so we don't need validate it continue diff --git a/kallithea/controllers/api/api.py b/kallithea/controllers/api/api.py --- a/kallithea/controllers/api/api.py +++ b/kallithea/controllers/api/api.py @@ -553,7 +553,7 @@ class ApiController(JSONRPCController): { "user_id" : "", "api_key" : "", - "api_keys": "[]" + "api_keys": "[]" "username" : "", "firstname": "", "lastname" : "", diff --git a/kallithea/lib/auth.py b/kallithea/lib/auth.py --- a/kallithea/lib/auth.py +++ b/kallithea/lib/auth.py @@ -146,7 +146,7 @@ def check_password(password, hashed): def generate_api_key(str_, salt=None): """ - Generates API KEY from given string + Generates API key from given string :param str_: :param salt: @@ -519,9 +519,9 @@ class AuthUser(object): log.debug('Auth User lookup by USER ID %s' % self.user_id) is_user_loaded = user_model.fill_data(self, user_id=self.user_id) - # try go get user by api key + # try go get user by API key elif self._api_key and self._api_key != self.anonymous_user.api_key: - log.debug('Auth User lookup by API KEY %s' % self._api_key) + log.debug('Auth User lookup by API key %s' % self._api_key) is_user_loaded = user_model.fill_data(self, api_key=self._api_key) # lookup by username diff --git a/kallithea/lib/dbmigrate/schema/db_2_2_0.py b/kallithea/lib/dbmigrate/schema/db_2_2_0.py --- a/kallithea/lib/dbmigrate/schema/db_2_2_0.py +++ b/kallithea/lib/dbmigrate/schema/db_2_2_0.py @@ -437,7 +437,7 @@ class User(Base, BaseModel): user_comments = relationship('ChangesetComment', cascade='all') #extra emails for this user user_emails = relationship('UserEmailMap', cascade='all') - #extra api keys + #extra API keys user_api_keys = relationship('UserApiKeys', cascade='all') diff --git a/kallithea/lib/dbmigrate/schema/db_2_2_3.py b/kallithea/lib/dbmigrate/schema/db_2_2_3.py --- a/kallithea/lib/dbmigrate/schema/db_2_2_3.py +++ b/kallithea/lib/dbmigrate/schema/db_2_2_3.py @@ -437,7 +437,7 @@ class User(Base, BaseModel): user_comments = relationship('ChangesetComment', cascade='all') #extra emails for this user user_emails = relationship('UserEmailMap', cascade='all') - #extra api keys + #extra API keys user_api_keys = relationship('UserApiKeys', cascade='all') diff --git a/kallithea/model/api_key.py b/kallithea/model/api_key.py --- a/kallithea/model/api_key.py +++ b/kallithea/model/api_key.py @@ -15,7 +15,7 @@ kallithea.model.api_key ~~~~~~~~~~~~~~~~~~~~~~~ -api key model for Kallithea +API key model for Kallithea This file was forked by the Kallithea project in July 2014. Original author and date, and relevant copyright and licensing information is below: diff --git a/kallithea/model/db.py b/kallithea/model/db.py --- a/kallithea/model/db.py +++ b/kallithea/model/db.py @@ -438,7 +438,7 @@ class User(Base, BaseModel): user_comments = relationship('ChangesetComment', cascade='all') #extra emails for this user user_emails = relationship('UserEmailMap', cascade='all') - #extra api keys + #extra API keys user_api_keys = relationship('UserApiKeys', cascade='all') diff --git a/kallithea/model/user.py b/kallithea/model/user.py --- a/kallithea/model/user.py +++ b/kallithea/model/user.py @@ -349,7 +349,7 @@ class UserModel(BaseModel): :param auth_user: instance of user to set attributes :param user_id: user id to fetch by - :param api_key: api key to fetch by + :param api_key: API key to fetch by :param username: username to fetch by """ if user_id is None and api_key is None and username is None: diff --git a/kallithea/templates/admin/my_account/my_account_api_keys.html b/kallithea/templates/admin/my_account/my_account_api_keys.html --- a/kallithea/templates/admin/my_account/my_account_api_keys.html +++ b/kallithea/templates/admin/my_account/my_account_api_keys.html @@ -11,7 +11,7 @@ ${h.hidden('del_api_key',c.user.api_key)} ${h.hidden('del_api_key_builtin',1)} ${h.end_form()} @@ -37,7 +37,7 @@ ${h.form(url('my_account_api_keys'),method='delete')} ${h.hidden('del_api_key',api_key.api_key)} @@ -46,7 +46,7 @@ %endfor %else: -
${_('No additional api keys specified')}
+
${_('No additional API keys specified')}
%endif @@ -58,7 +58,7 @@
- +
${h.text('description', class_='medium', placeholder=_('Description'))} diff --git a/kallithea/templates/admin/users/user_edit_api_keys.html b/kallithea/templates/admin/users/user_edit_api_keys.html --- a/kallithea/templates/admin/users/user_edit_api_keys.html +++ b/kallithea/templates/admin/users/user_edit_api_keys.html @@ -11,7 +11,7 @@ ${h.hidden('del_api_key',c.user.api_key)} ${h.hidden('del_api_key_builtin',1)} ${h.end_form()} @@ -37,7 +37,7 @@ ${h.form(url('edit_user_api_keys', id=c.user.user_id),method='delete')} ${h.hidden('del_api_key',api_key.api_key)} @@ -46,7 +46,7 @@ %endfor %else: -
${_('No additional api keys specified')}
+
${_('No additional API keys specified')}
%endif
@@ -58,7 +58,7 @@
- +
${h.text('description', class_='medium', placeholder=_('Description'))} diff --git a/kallithea/tests/api/api_base.py b/kallithea/tests/api/api_base.py --- a/kallithea/tests/api/api_base.py +++ b/kallithea/tests/api/api_base.py @@ -166,7 +166,7 @@ class _BaseTestApi(object): id_, params = _build_data('trololo', 'get_user') response = api_call(self, params) - expected = 'Invalid API KEY' + expected = 'Invalid API key' self._compare_error(id_, expected, given=response.body) def test_api_missing_non_optional_param(self): diff --git a/kallithea/tests/functional/test_admin_users.py b/kallithea/tests/functional/test_admin_users.py --- a/kallithea/tests/functional/test_admin_users.py +++ b/kallithea/tests/functional/test_admin_users.py @@ -452,7 +452,7 @@ class TestAdminUsersController(TestContr response = self.app.post(url('edit_user_api_keys', id=user_id), {'_method': 'put', 'description': desc, 'lifetime': lifetime, '_authentication_token': self.authentication_token()}) - self.checkSessionFlash(response, 'Api key successfully created') + self.checkSessionFlash(response, 'API key successfully created') try: response = response.follow() user = User.get(user_id) @@ -470,7 +470,7 @@ class TestAdminUsersController(TestContr response = self.app.post(url('edit_user_api_keys', id=user_id), {'_method': 'put', 'description': 'desc', 'lifetime': -1, '_authentication_token': self.authentication_token()}) - self.checkSessionFlash(response, 'Api key successfully created') + self.checkSessionFlash(response, 'API key successfully created') response = response.follow() #now delete our key @@ -479,7 +479,7 @@ class TestAdminUsersController(TestContr response = self.app.post(url('edit_user_api_keys', id=user_id), {'_method': 'delete', 'del_api_key': keys[0].api_key, '_authentication_token': self.authentication_token()}) - self.checkSessionFlash(response, 'Api key successfully deleted') + self.checkSessionFlash(response, 'API key successfully deleted') keys = UserApiKeys.query().filter(UserApiKeys.user_id == user_id).all() self.assertEqual(0, len(keys)) @@ -494,6 +494,6 @@ class TestAdminUsersController(TestContr response = self.app.post(url('edit_user_api_keys', id=user_id), {'_method': 'delete', 'del_api_key_builtin': api_key, '_authentication_token': self.authentication_token()}) - self.checkSessionFlash(response, 'Api key successfully reset') + self.checkSessionFlash(response, 'API key successfully reset') response = response.follow() response.mustcontain(no=[api_key]) diff --git a/kallithea/tests/functional/test_login.py b/kallithea/tests/functional/test_login.py --- a/kallithea/tests/functional/test_login.py +++ b/kallithea/tests/functional/test_login.py @@ -363,7 +363,7 @@ class TestLoginController(TestController new_api_key = ApiKeyModel().create(TEST_USER_ADMIN_LOGIN, u'test') Session().commit() - #patch the api key and make it expired + #patch the API key and make it expired new_api_key.expires = 0 Session().add(new_api_key) Session().commit() diff --git a/kallithea/tests/functional/test_my_account.py b/kallithea/tests/functional/test_my_account.py --- a/kallithea/tests/functional/test_my_account.py +++ b/kallithea/tests/functional/test_my_account.py @@ -201,7 +201,7 @@ class TestMyAccountController(TestContro user = User.get(usr['user_id']) response = self.app.post(url('my_account_api_keys'), {'description': desc, 'lifetime': lifetime, '_authentication_token': self.authentication_token()}) - self.checkSessionFlash(response, 'Api key successfully created') + self.checkSessionFlash(response, 'API key successfully created') try: response = response.follow() user = User.get(usr['user_id']) @@ -217,7 +217,7 @@ class TestMyAccountController(TestContro user = User.get(usr['user_id']) response = self.app.post(url('my_account_api_keys'), {'description': 'desc', 'lifetime': -1, '_authentication_token': self.authentication_token()}) - self.checkSessionFlash(response, 'Api key successfully created') + self.checkSessionFlash(response, 'API key successfully created') response = response.follow() #now delete our key @@ -226,7 +226,7 @@ class TestMyAccountController(TestContro response = self.app.post(url('my_account_api_keys'), {'_method': 'delete', 'del_api_key': keys[0].api_key, '_authentication_token': self.authentication_token()}) - self.checkSessionFlash(response, 'Api key successfully deleted') + self.checkSessionFlash(response, 'API key successfully deleted') keys = UserApiKeys.query().all() self.assertEqual(0, len(keys)) @@ -241,6 +241,6 @@ class TestMyAccountController(TestContro response = self.app.post(url('my_account_api_keys'), {'_method': 'delete', 'del_api_key_builtin': api_key, '_authentication_token': self.authentication_token()}) - self.checkSessionFlash(response, 'Api key successfully reset') + self.checkSessionFlash(response, 'API key successfully reset') response = response.follow() response.mustcontain(no=[api_key])