Add pagination
This commit is contained in:
@@ -12,6 +12,7 @@ from atst.domain.users import Users
|
||||
from atst.domain.authnid import AuthenticationContext
|
||||
from atst.domain.audit_log import AuditLog
|
||||
from atst.domain.auth import logout as _logout
|
||||
from atst.domain.common import Paginator
|
||||
from atst.utils.flash import formatted_flash as flash
|
||||
|
||||
|
||||
@@ -126,16 +127,9 @@ def logout():
|
||||
return redirect(url_for(".root"))
|
||||
|
||||
|
||||
def get_pagination_opts(request, default_page=1, default_per_page=100):
|
||||
return {
|
||||
"page": int(request.args.get("page", default_page)),
|
||||
"per_page": int(request.args.get("perPage", default_per_page)),
|
||||
}
|
||||
|
||||
|
||||
@bp.route("/activity-history")
|
||||
def activity_history():
|
||||
pagination_opts = get_pagination_opts(request)
|
||||
pagination_opts = Paginator.get_pagination_opts(request)
|
||||
audit_events = AuditLog.get_all_events(g.current_user, pagination_opts)
|
||||
return render_template("audit_log/audit_log.html", audit_events=audit_events)
|
||||
|
||||
|
@@ -7,6 +7,7 @@ from atst.domain.reports import Reports
|
||||
from atst.domain.workspaces import Workspaces
|
||||
from atst.domain.audit_log import AuditLog
|
||||
from atst.domain.authz import Authorization
|
||||
from atst.domain.common import Paginator
|
||||
from atst.forms.workspace import WorkspaceForm
|
||||
from atst.models.permissions import Permissions
|
||||
|
||||
@@ -87,16 +88,16 @@ def workspace_reports(workspace_id):
|
||||
def workspace_activity(workspace_id):
|
||||
workspace = Workspaces.get(g.current_user, workspace_id)
|
||||
Authorization.check_workspace_permission(
|
||||
g.current_user,
|
||||
workspace,
|
||||
# TODO: diff permission
|
||||
Permissions.VIEW_USAGE_DOLLARS,
|
||||
"view workspace reports",
|
||||
g.current_user, workspace, Permissions.VIEW_AUDIT_LOG, "view workspace reports"
|
||||
)
|
||||
pagination_opts = Paginator.get_pagination_opts(http_request)
|
||||
audit_events = AuditLog.get_workspace_events(
|
||||
g.current_user, workspace_id, pagination_opts
|
||||
)
|
||||
audit_events = AuditLog.get_workspace_events(workspace_id)
|
||||
|
||||
return render_template(
|
||||
"workspaces/activity/index.html",
|
||||
workspace_name=workspace.name,
|
||||
workspace_id=workspace_id,
|
||||
audit_events=audit_events,
|
||||
)
|
||||
|
Reference in New Issue
Block a user