# HG changeset patch # User Marcin Kuzminski # Date 2017-06-14 09:51:46 # Node ID bf108a7c45451f217499768f76df96cd78437d92 # Parent 2007cb9bc2408689db30a34d8071f5086b2d3043 audit-logs: implement enum sources that should be re-used. diff --git a/rhodecode/api/views/repo_api.py b/rhodecode/api/views/repo_api.py --- a/rhodecode/api/views/repo_api.py +++ b/rhodecode/api/views/repo_api.py @@ -1181,7 +1181,8 @@ def delete_repo(request, apiuser, repoid audit_logger.store( action='repo.delete', - action_data={'repo_data': repo_data, 'source': 'api_call'}, + action_data={'repo_data': repo_data, + 'source': audit_logger.SOURCE_API}, user=apiuser, repo=repo, commit=False) ScmModel().mark_for_invalidation(repo_name, delete=True) diff --git a/rhodecode/apps/repository/views/repo_settings_advanced.py b/rhodecode/apps/repository/views/repo_settings_advanced.py --- a/rhodecode/apps/repository/views/repo_settings_advanced.py +++ b/rhodecode/apps/repository/views/repo_settings_advanced.py @@ -101,7 +101,8 @@ class RepoSettingsView(RepoAppView): repo_name=self.db_repo.repo_name) audit_logger.store( action='repo.delete', - action_data={'repo_data': repo_data, 'source': 'web_action'}, + action_data={'repo_data': repo_data, + 'source': audit_logger.SOURCE_WEB}, user=self._rhodecode_user, repo=repo, commit=False) ScmModel().mark_for_invalidation(self.db_repo_name, delete=True) diff --git a/rhodecode/lib/audit_logger.py b/rhodecode/lib/audit_logger.py --- a/rhodecode/lib/audit_logger.py +++ b/rhodecode/lib/audit_logger.py @@ -44,6 +44,9 @@ ACTIONS = { 'repo.archive.download': {}, } +SOURCE_WEB = 'source_web' +SOURCE_API = 'source_api' + class UserWrap(object): """ @@ -114,7 +117,8 @@ def store( # repo action, when we know and have the repository object already audit_logger.store( action='repo.delete', - user=audit_logger.UserWrap(username='itried-login', ip_addr='8.8.8.8'), + action_data={'source': audit_logger.SOURCE_WEB, }, + user=self._rhodecode_user, repo=repo_object) # without an user ?