##// END OF EJS Templates
vcs-ops: store user_id inside the extras for vcs context operations....
marcink -
r2411:f2cd50d7 default
parent child Browse files
Show More
@@ -93,6 +93,7 b' class VcsServer(object):'
93 93 scm_data = {
94 94 'ip': os.environ['SSH_CLIENT'].split()[0],
95 95 'username': self.user.username,
96 'user_id': self.user.user_id,
96 97 'action': action,
97 98 'repository': self.repo_name,
98 99 'scm': self.backend,
@@ -127,6 +127,7 b' class TestGitServer(object):'
127 127
128 128 expected_data = {
129 129 'username': git_server.user.username,
130 'user_id': git_server.user.user_id,
130 131 'scm': 'git',
131 132 'repository': git_server.repo_name,
132 133 'make_lock': None,
@@ -169,19 +169,20 b' def vcs_operation_context('
169 169 make_lock = None
170 170 locked_by = [None, None, None]
171 171 is_anonymous = username == User.DEFAULT_USER
172 user = User.get_by_username(username)
172 173 if not is_anonymous and check_locking:
173 174 log.debug('Checking locking on repository "%s"', repo_name)
174 user = User.get_by_username(username)
175 175 repo = Repository.get_by_repo_name(repo_name)
176 176 make_lock, __, locked_by = repo.get_locking_state(
177 177 action, user.user_id)
178
178 user_id = user.user_id
179 179 settings_model = VcsSettingsModel(repo=repo_name)
180 180 ui_settings = settings_model.get_ui_settings()
181 181
182 182 extras = {
183 183 'ip': get_ip_addr(environ),
184 184 'username': username,
185 'user_id': user_id,
185 186 'action': action,
186 187 'repository': repo_name,
187 188 'scm': scm,
@@ -37,6 +37,7 b' def scm_extras(user_regular, repo_stub):'
37 37 extras = utils2.AttributeDict({
38 38 'ip': '127.0.0.1',
39 39 'username': user_regular.username,
40 'user_id': user_regular.user_id,
40 41 'action': '',
41 42 'repository': repo_stub.repo_name,
42 43 'scm': repo_stub.scm_instance().alias,
@@ -37,6 +37,7 b' def repo_push_event(backend, user_regula'
37 37 scm_extras = {
38 38 'ip': '127.0.0.1',
39 39 'username': user_regular.username,
40 'user_id': user_regular.user_id,
40 41 'action': '',
41 42 'repository': repo.repo_name,
42 43 'scm': repo.scm_instance().alias,
@@ -72,6 +72,8 b' def test_vcs_operation_context_can_skip_'
72 72 base, 'get_enabled_hook_classes', Mock(return_value=['stub_hook']))
73 73 @patch('rhodecode.lib.utils2.get_server_url',
74 74 Mock(return_value='https://example.com'))
75 @patch.object(db.User, 'get_by_username',
76 Mock(return_value=Mock(return_value=1)))
75 77 def call_vcs_operation_context(**kwargs_override):
76 78 kwargs = {
77 79 'repo_name': 'stub_repo_name',
@@ -28,6 +28,7 b' def test_post_push_truncates_commits(use'
28 28 extras = {
29 29 'ip': '127.0.0.1',
30 30 'username': user_regular.username,
31 'user_id': user_regular.user_id,
31 32 'action': 'push_local',
32 33 'repository': repo_stub.repo_name,
33 34 'scm': 'git',
@@ -64,6 +65,7 b' def hook_extras(user_regular, repo_stub)'
64 65 extras = utils2.AttributeDict({
65 66 'ip': '127.0.0.1',
66 67 'username': user_regular.username,
68 'user_id': user_regular.user_id,
67 69 'action': 'push',
68 70 'repository': repo_stub.repo_name,
69 71 'scm': '',
@@ -458,6 +458,7 b' def merge_extras(user_regular):'
458 458 extras = {
459 459 'ip': '127.0.0.1',
460 460 'username': user_regular.username,
461 'user_id': user_regular.user_id,
461 462 'action': 'push',
462 463 'repository': 'fake_target_repo_name',
463 464 'scm': 'git',
General Comments 0
You need to be logged in to leave comments. Login now