Jul 22 - Update - add audit viewer, CSRF lifetime
This commit is contained in:
@@ -9,7 +9,7 @@ from flask import (
|
||||
)
|
||||
from werkzeug.security import check_password_hash
|
||||
|
||||
from app import db, log_action, Section, Topic
|
||||
from app import db, log_action, AuditLog, Section, Topic
|
||||
|
||||
admin_bp = Blueprint("admin", __name__, url_prefix="/admin")
|
||||
|
||||
@@ -108,6 +108,35 @@ def dashboard():
|
||||
return render_template("admin/dashboard.html", sections=sections)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ audit log
|
||||
@admin_bp.route("/audit")
|
||||
@login_required
|
||||
def audit():
|
||||
page = _int(request.args.get("page"), 1)
|
||||
if page < 1:
|
||||
page = 1
|
||||
action = request.args.get("action", "")
|
||||
entity = request.args.get("entity", "")
|
||||
|
||||
q = AuditLog.query
|
||||
if action in ("create", "update", "delete"):
|
||||
q = q.filter(AuditLog.action == action)
|
||||
if entity in ("section", "topic"):
|
||||
q = q.filter(AuditLog.entity == entity)
|
||||
|
||||
pagination = (
|
||||
q.order_by(AuditLog.created_at.desc(), AuditLog.id.desc())
|
||||
.paginate(page=page, per_page=50, error_out=False)
|
||||
)
|
||||
return render_template(
|
||||
"admin/audit.html",
|
||||
pagination=pagination,
|
||||
entries=pagination.items,
|
||||
action=action,
|
||||
entity=entity,
|
||||
)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ topics
|
||||
@admin_bp.route("/topic/new", methods=["GET", "POST"])
|
||||
@admin_bp.route("/topic/<int:topic_id>", methods=["GET", "POST"])
|
||||
|
||||
Reference in New Issue
Block a user