Interface out all action log data model operations
This will allow us to reimplement the logs data model against a non-database system in the near future
This commit is contained in:
parent
a156c91962
commit
b773a18ed8
26 changed files with 714 additions and 902 deletions
|
@ -18,6 +18,8 @@ from auth import scopes
|
|||
from auth.auth_context import (get_authenticated_context, get_authenticated_user,
|
||||
get_validated_oauth_token)
|
||||
from auth.decorators import process_oauth
|
||||
from data.logs_model import logs_model
|
||||
from data import model as data_model
|
||||
from endpoints.csrf import csrf_protect
|
||||
from endpoints.exception import (Unauthorized, InvalidRequest, InvalidResponse,
|
||||
FreshLoginRequired, NotFound)
|
||||
|
@ -365,7 +367,7 @@ def request_error(exception=None, **kwargs):
|
|||
def log_action(kind, user_or_orgname, metadata=None, repo=None, repo_name=None):
|
||||
if not metadata:
|
||||
metadata = {}
|
||||
|
||||
|
||||
oauth_token = get_validated_oauth_token()
|
||||
if oauth_token:
|
||||
metadata['oauth_token_id'] = oauth_token.id
|
||||
|
@ -373,11 +375,15 @@ def log_action(kind, user_or_orgname, metadata=None, repo=None, repo_name=None):
|
|||
metadata['oauth_token_application'] = oauth_token.application.name
|
||||
|
||||
performer = get_authenticated_user()
|
||||
|
||||
if repo:
|
||||
repo_name = repo.name
|
||||
|
||||
model.log_action(kind, user_or_orgname, repo_name, performer, request.remote_addr, metadata)
|
||||
|
||||
if repo_name is not None:
|
||||
repo = data_model.repository.get_repository(user_or_orgname, repo_name)
|
||||
|
||||
logs_model.log_action(kind, user_or_orgname,
|
||||
repository=repo,
|
||||
performer=performer,
|
||||
ip=request.remote_addr,
|
||||
metadata=metadata)
|
||||
|
||||
|
||||
def define_json_response(schema_name):
|
||||
|
|
Reference in a new issue