Changeset - 2d0de5aa95d1
[Not reviewed]
default
0 3 0
Mads Kiilerich - 9 years ago 2017-04-07 04:22:42
mads@kiilerich.com
lib: pass full user to _check_locking_state - not just user_id
3 files changed with 5 insertions and 12 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/base.py
Show inline comments
 
@@ -324,7 +324,7 @@ class BaseVCSController(object):
 
    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 @@ class BaseVCSController(object):
 
        """
 
        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':
kallithea/lib/middleware/simplegit.py
Show inline comments
 
@@ -36,7 +36,7 @@ import traceback
 
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 @@ class SimpleGit(BaseVCSController):
 
        # 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})
kallithea/lib/middleware/simplehg.py
Show inline comments
 
@@ -34,7 +34,6 @@ import traceback
 

	
 
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 @@ class SimpleHg(BaseVCSController):
 
        # 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})
0 comments (0 inline, 0 general)