mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 14:32:25 +01:00
Add audit logging to type editors
This commit is contained in:
parent
f03746f5ad
commit
e88ead392b
@ -16,13 +16,14 @@
|
|||||||
|
|
||||||
|
|
||||||
from flask import redirect, render_template, abort, url_for, request, flash
|
from flask import redirect, render_template, abort, url_for, request, flash
|
||||||
|
from flask_login import current_user
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from wtforms import StringField, BooleanField, SubmitField, URLField
|
from wtforms import StringField, BooleanField, SubmitField, URLField
|
||||||
from wtforms.validators import InputRequired, Length, Optional
|
from wtforms.validators import InputRequired, Length, Optional
|
||||||
|
|
||||||
from app.utils import rank_required, nonEmptyOrNone
|
from app.utils import rank_required, nonEmptyOrNone, addAuditLog
|
||||||
from . import bp
|
from . import bp
|
||||||
from ...models import UserRank, License, db
|
from ...models import UserRank, License, db, AuditSeverity
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/licenses/")
|
@bp.route("/licenses/")
|
||||||
@ -56,9 +57,15 @@ def create_edit_license(name=None):
|
|||||||
license = License(form.name.data)
|
license = License(form.name.data)
|
||||||
db.session.add(license)
|
db.session.add(license)
|
||||||
flash("Created license " + form.name.data, "success")
|
flash("Created license " + form.name.data, "success")
|
||||||
|
|
||||||
|
addAuditLog(AuditSeverity.MODERATION, current_user, f"Created license {license.name}",
|
||||||
|
url_for("admin.license_list"))
|
||||||
else:
|
else:
|
||||||
flash("Updated license " + form.name.data, "success")
|
flash("Updated license " + form.name.data, "success")
|
||||||
|
|
||||||
|
addAuditLog(AuditSeverity.MODERATION, current_user, f"Edited license {license.name}",
|
||||||
|
url_for("admin.license_list"))
|
||||||
|
|
||||||
form.populate_obj(license)
|
form.populate_obj(license)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return redirect(url_for("admin.license_list"))
|
return redirect(url_for("admin.license_list"))
|
||||||
|
@ -22,7 +22,8 @@ from wtforms import StringField, TextAreaField, BooleanField, SubmitField
|
|||||||
from wtforms.validators import InputRequired, Length, Optional, Regexp
|
from wtforms.validators import InputRequired, Length, Optional, Regexp
|
||||||
|
|
||||||
from . import bp
|
from . import bp
|
||||||
from ...models import Permission, Tag, db
|
from ...models import Permission, Tag, db, AuditSeverity
|
||||||
|
from ...utils import addAuditLog
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/tags/")
|
@bp.route("/tags/")
|
||||||
@ -69,9 +70,15 @@ def create_edit_tag(name=None):
|
|||||||
tag.description = form.description.data
|
tag.description = form.description.data
|
||||||
tag.is_protected = form.is_protected.data
|
tag.is_protected = form.is_protected.data
|
||||||
db.session.add(tag)
|
db.session.add(tag)
|
||||||
|
|
||||||
|
addAuditLog(AuditSeverity.EDITOR, current_user, f"Created tag {tag.name}",
|
||||||
|
url_for("admin.create_edit_tag", name=tag.name))
|
||||||
else:
|
else:
|
||||||
form.populate_obj(tag)
|
form.populate_obj(tag)
|
||||||
|
|
||||||
|
addAuditLog(AuditSeverity.EDITOR, current_user, f"Edited tag {tag.name}",
|
||||||
|
url_for("admin.create_edit_tag", name=tag.name))
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
if Permission.EDIT_TAGS.check(current_user):
|
if Permission.EDIT_TAGS.check(current_user):
|
||||||
|
@ -16,13 +16,14 @@
|
|||||||
|
|
||||||
|
|
||||||
from flask import redirect, render_template, abort, url_for, request, flash
|
from flask import redirect, render_template, abort, url_for, request, flash
|
||||||
|
from flask_login import current_user
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from wtforms import StringField, IntegerField, SubmitField
|
from wtforms import StringField, IntegerField, SubmitField
|
||||||
from wtforms.validators import InputRequired, Length
|
from wtforms.validators import InputRequired, Length
|
||||||
|
|
||||||
from app.utils import rank_required
|
from app.utils import rank_required, addAuditLog
|
||||||
from . import bp
|
from . import bp
|
||||||
from ...models import UserRank, MinetestRelease, db
|
from ...models import UserRank, MinetestRelease, db, AuditSeverity
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/versions/")
|
@bp.route("/versions/")
|
||||||
@ -53,9 +54,15 @@ def create_edit_version(name=None):
|
|||||||
version = MinetestRelease(form.name.data)
|
version = MinetestRelease(form.name.data)
|
||||||
db.session.add(version)
|
db.session.add(version)
|
||||||
flash("Created version " + form.name.data, "success")
|
flash("Created version " + form.name.data, "success")
|
||||||
|
|
||||||
|
addAuditLog(AuditSeverity.MODERATION, current_user, f"Created version {version.name}",
|
||||||
|
url_for("admin.license_list"))
|
||||||
else:
|
else:
|
||||||
flash("Updated version " + form.name.data, "success")
|
flash("Updated version " + form.name.data, "success")
|
||||||
|
|
||||||
|
addAuditLog(AuditSeverity.MODERATION, current_user, f"Edited version {version.name}",
|
||||||
|
url_for("admin.version_list"))
|
||||||
|
|
||||||
form.populate_obj(version)
|
form.populate_obj(version)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return redirect(url_for("admin.version_list"))
|
return redirect(url_for("admin.version_list"))
|
||||||
|
Loading…
Reference in New Issue
Block a user