Display audit logs for current workspace
This commit is contained in:
parent
bf22afa7af
commit
3731dd876e
@ -25,6 +25,15 @@ class AuditLog(object):
|
||||
)
|
||||
return AuditEventQuery.get_all(pagination_opts)
|
||||
|
||||
@classmethod
|
||||
def get_workspace_events(cls, workspace_id):
|
||||
return (
|
||||
db.session.query(AuditEvent)
|
||||
.filter(AuditEvent.workspace_id == workspace_id)
|
||||
.order_by(AuditEvent.time_created.desc())
|
||||
.all()
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_by_resource(cls, resource_id):
|
||||
return (
|
||||
|
@ -5,8 +5,9 @@ from flask import render_template, request as http_request, g, redirect, url_for
|
||||
from . import workspaces_bp
|
||||
from atst.domain.reports import Reports
|
||||
from atst.domain.workspaces import Workspaces
|
||||
from atst.forms.workspace import WorkspaceForm
|
||||
from atst.domain.audit_log import AuditLog
|
||||
from atst.domain.authz import Authorization
|
||||
from atst.forms.workspace import WorkspaceForm
|
||||
from atst.models.permissions import Permissions
|
||||
|
||||
|
||||
@ -92,5 +93,10 @@ def workspace_activity(workspace_id):
|
||||
Permissions.VIEW_USAGE_DOLLARS,
|
||||
"view workspace reports",
|
||||
)
|
||||
audit_events = AuditLog.get_workspace_events(workspace_id)
|
||||
|
||||
return render_template("workspaces/activity.html", workspace_name=workspace.name)
|
||||
return render_template(
|
||||
"workspaces/activity/index.html",
|
||||
workspace_name=workspace.name,
|
||||
audit_events=audit_events,
|
||||
)
|
||||
|
@ -1 +0,0 @@
|
||||
<h1>Activity Log for Workspace {{workspace_name}}</h1>
|
23
templates/workspaces/activity/index.html
Normal file
23
templates/workspaces/activity/index.html
Normal file
@ -0,0 +1,23 @@
|
||||
{% extends "workspaces/base.html" %}
|
||||
|
||||
{% block workspace_content %}
|
||||
|
||||
<div v-cloak>
|
||||
<section class="block-list">
|
||||
<header class="block-list__header">
|
||||
<h1 class="block-list__title">{{ "audit_log.header_title" | translate }}</h1>
|
||||
</header>
|
||||
|
||||
<ul>
|
||||
{% for event in audit_events %}
|
||||
<li class="block-list__item">
|
||||
{% autoescape false %}
|
||||
{{ event | renderAuditEvent }}
|
||||
{% endautoescape %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user