##// END OF EJS Templates
audit-logs: store properly IP and user for certain comments types....
marcink -
r2728:9f3cefa1 default
parent child Browse files
Show More
@@ -548,7 +548,8 b' def comment_pull_request('
548 closing_pr=False,
548 closing_pr=False,
549 renderer=renderer,
549 renderer=renderer,
550 comment_type=comment_type,
550 comment_type=comment_type,
551 resolves_comment_id=resolves_comment_id
551 resolves_comment_id=resolves_comment_id,
552 auth_user=apiuser
552 )
553 )
553
554
554 if allowed_to_change_status and status:
555 if allowed_to_change_status and status:
@@ -1469,7 +1469,8 b' def comment_commit('
1469 status_change_type=status,
1469 status_change_type=status,
1470 renderer=renderer,
1470 renderer=renderer,
1471 comment_type=comment_type,
1471 comment_type=comment_type,
1472 resolves_comment_id=resolves_comment_id
1472 resolves_comment_id=resolves_comment_id,
1473 auth_user=apiuser
1473 )
1474 )
1474 if status:
1475 if status:
1475 # also do a status change
1476 # also do a status change
@@ -437,7 +437,8 b' class RepoCommitsView(RepoAppView):'
437 if status else None),
437 if status else None),
438 status_change_type=status,
438 status_change_type=status,
439 comment_type=comment_type,
439 comment_type=comment_type,
440 resolves_comment_id=resolves_comment_id
440 resolves_comment_id=resolves_comment_id,
441 auth_user=self._rhodecode_user
441 )
442 )
442
443
443 # get status if set !
444 # get status if set !
@@ -528,7 +529,7 b' class RepoCommitsView(RepoAppView):'
528 comment_repo_admin = is_repo_admin and is_repo_comment
529 comment_repo_admin = is_repo_admin and is_repo_comment
529
530
530 if super_admin or comment_owner or comment_repo_admin:
531 if super_admin or comment_owner or comment_repo_admin:
531 CommentsModel().delete(comment=comment, user=self._rhodecode_db_user)
532 CommentsModel().delete(comment=comment, auth_user=self._rhodecode_user)
532 Session().commit()
533 Session().commit()
533 return True
534 return True
534 else:
535 else:
@@ -1285,7 +1285,7 b' class RepoPullRequestsView(RepoAppView, '
1285
1285
1286 if super_admin or comment_owner or comment_repo_admin:
1286 if super_admin or comment_owner or comment_repo_admin:
1287 old_calculated_status = comment.pull_request.calculated_review_status()
1287 old_calculated_status = comment.pull_request.calculated_review_status()
1288 CommentsModel().delete(comment=comment, user=self._rhodecode_user)
1288 CommentsModel().delete(comment=comment, auth_user=self._rhodecode_user)
1289 Session().commit()
1289 Session().commit()
1290 calculated_status = comment.pull_request.calculated_review_status()
1290 calculated_status = comment.pull_request.calculated_review_status()
1291 if old_calculated_status != calculated_status:
1291 if old_calculated_status != calculated_status:
@@ -159,18 +159,18 b' class CommentsModel(BaseModel):'
159
159
160 return todos
160 return todos
161
161
162 def _log_audit_action(self, action, action_data, user, comment):
162 def _log_audit_action(self, action, action_data, auth_user, comment):
163 audit_logger.store(
163 audit_logger.store(
164 action=action,
164 action=action,
165 action_data=action_data,
165 action_data=action_data,
166 user=user,
166 user=auth_user,
167 repo=comment.repo)
167 repo=comment.repo)
168
168
169 def create(self, text, repo, user, commit_id=None, pull_request=None,
169 def create(self, text, repo, user, commit_id=None, pull_request=None,
170 f_path=None, line_no=None, status_change=None,
170 f_path=None, line_no=None, status_change=None,
171 status_change_type=None, comment_type=None,
171 status_change_type=None, comment_type=None,
172 resolves_comment_id=None, closing_pr=False, send_email=True,
172 resolves_comment_id=None, closing_pr=False, send_email=True,
173 renderer=None):
173 renderer=None, auth_user=None):
174 """
174 """
175 Creates new comment for commit or pull request.
175 Creates new comment for commit or pull request.
176 IF status_change is not none this comment is associated with a
176 IF status_change is not none this comment is associated with a
@@ -190,6 +190,8 b' class CommentsModel(BaseModel):'
190 :param send_email:
190 :param send_email:
191 :param renderer: pick renderer for this comment
191 :param renderer: pick renderer for this comment
192 """
192 """
193
194 auth_user = auth_user or user
193 if not text:
195 if not text:
194 log.warning('Missing text for comment, skipping...')
196 log.warning('Missing text for comment, skipping...')
195 return
197 return
@@ -355,7 +357,7 b' class CommentsModel(BaseModel):'
355
357
356 comment_data = comment.get_api_data()
358 comment_data = comment.get_api_data()
357 self._log_audit_action(
359 self._log_audit_action(
358 action, {'data': comment_data}, user, comment)
360 action, {'data': comment_data}, auth_user, comment)
359
361
360 msg_url = ''
362 msg_url = ''
361 channel = None
363 channel = None
@@ -388,7 +390,7 b' class CommentsModel(BaseModel):'
388
390
389 return comment
391 return comment
390
392
391 def delete(self, comment, user):
393 def delete(self, comment, auth_user):
392 """
394 """
393 Deletes given comment
395 Deletes given comment
394 """
396 """
@@ -402,7 +404,7 b' class CommentsModel(BaseModel):'
402 action = 'repo.commit.comment.delete'
404 action = 'repo.commit.comment.delete'
403
405
404 self._log_audit_action(
406 self._log_audit_action(
405 action, {'old_data': old_data}, user, comment)
407 action, {'old_data': old_data}, auth_user, comment)
406
408
407 return comment
409 return comment
408
410
General Comments 0
You need to be logged in to leave comments. Login now