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