# HG changeset patch # User Mads Kiilerich # Date 1491531762 -7200 # Node ID 2d0de5aa95d15c30ba3b96996001e71edeee1724 # Parent 8eda7bc543cd1aed3ebb05305a74e862807481bb lib: pass full user to _check_locking_state - not just user_id diff -r 8eda7bc543cd -r 2d0de5aa95d1 kallithea/lib/base.py --- a/kallithea/lib/base.py Fri Apr 07 04:21:38 2017 +0200 +++ b/kallithea/lib/base.py Fri Apr 07 04:22:42 2017 +0200 @@ -324,7 +324,7 @@ def _get_ip_addr(self, environ): return _get_ip_addr(environ) - def _check_locking_state(self, action, repo, user_id): + def _check_locking_state(self, action, repo_name, user): """ Checks locking on this repository, if locking is enabled, and if lock is present. Returns a tuple of make_lock, locked, locked_by. make_lock @@ -334,9 +334,7 @@ """ locked = False # defines that locked error should be thrown to user make_lock = None - repo = Repository.get_by_repo_name(repo) - user = User.get(user_id) - + repo = Repository.get_by_repo_name(repo_name) locked_by = repo.locked if repo and repo.enable_locking: if action == 'push': diff -r 8eda7bc543cd -r 2d0de5aa95d1 kallithea/lib/middleware/simplegit.py --- a/kallithea/lib/middleware/simplegit.py Fri Apr 07 04:21:38 2017 +0200 +++ b/kallithea/lib/middleware/simplegit.py Fri Apr 07 04:22:42 2017 +0200 @@ -36,7 +36,7 @@ from paste.httpheaders import REMOTE_USER, AUTH_TYPE from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \ HTTPNotAcceptable -from kallithea.model.db import User, Ui +from kallithea.model.db import Ui from kallithea.lib.utils2 import safe_str, safe_unicode, fix_PATH, get_server_url, \ _set_extras @@ -124,9 +124,7 @@ # CHECK LOCKING only if it's not ANONYMOUS USER if not user.is_default_user: log.debug('Checking locking on repository') - (make_lock, - locked, - locked_by) = self._check_locking_state(action, repo_name, user.user_id) + make_lock, locked, locked_by = self._check_locking_state(action, repo_name, user) # store the make_lock for later evaluation in hooks extras.update({'make_lock': make_lock, 'locked_by': locked_by}) diff -r 8eda7bc543cd -r 2d0de5aa95d1 kallithea/lib/middleware/simplehg.py --- a/kallithea/lib/middleware/simplehg.py Fri Apr 07 04:21:38 2017 +0200 +++ b/kallithea/lib/middleware/simplehg.py Fri Apr 07 04:22:42 2017 +0200 @@ -34,7 +34,6 @@ from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \ HTTPNotAcceptable, HTTPBadRequest -from kallithea.model.db import User from kallithea.lib.utils2 import safe_str, safe_unicode, fix_PATH, get_server_url, \ _set_extras @@ -134,9 +133,7 @@ # CHECK LOCKING only if it's not ANONYMOUS USER elif not user.is_default_user: log.debug('Checking locking on repository') - (make_lock, - locked, - locked_by) = self._check_locking_state(action, repo_name, user.user_id) + make_lock, locked, locked_by = self._check_locking_state(action, repo_name, user) # store the make_lock for later evaluation in hooks extras.update({'make_lock': make_lock, 'locked_by': locked_by})