aboutsummaryrefslogtreecommitdiff
path: root/app/blueprints/packages/packages.py
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2020-07-11 02:32:17 +0100
committerrubenwardy <rw@rubenwardy.com>2020-07-11 02:32:17 +0100
commita4dd4f04293b6ad6dab5d3dc0a4c52a3290b4394 (patch)
tree8e56f86e0318bd41266ad4cf9178269fe6da4dbb /app/blueprints/packages/packages.py
parentbf927c50f00bd15c7bc1765b7d5fb0c6a6abeb86 (diff)
downloadcheatdb-a4dd4f04293b6ad6dab5d3dc0a4c52a3290b4394.tar.xz
Add audit log
Diffstat (limited to 'app/blueprints/packages/packages.py')
-rw-r--r--app/blueprints/packages/packages.py30
1 files changed, 21 insertions, 9 deletions
diff --git a/app/blueprints/packages/packages.py b/app/blueprints/packages/packages.py
index 3f26444..4743a57 100644
--- a/app/blueprints/packages/packages.py
+++ b/app/blueprints/packages/packages.py
@@ -265,8 +265,13 @@ def create_edit(author=None, name=None):
return redirect(url_for("packages.create_edit", author=author, name=name))
else:
+ msg = "Edited {}".format(package.title)
+
addNotification(package.maintainers, current_user,
- "Edited {}".format(package.title), package.getDetailsURL(), package)
+ msg, package.getDetailsURL(), package)
+
+ severity = AuditSeverity.NORMAL if current_user in package.maintainers else AuditSeverity.EDITOR
+ addAuditLog(severity, current_user, msg, package.getDetailsURL(), package)
form.populate_obj(package) # copy to row
@@ -337,8 +342,10 @@ def approve(package):
for s in screenshots:
s.approved = True
- addNotification(package.maintainers, current_user,
- "Approved {}".format(package.title), package.getDetailsURL(), package)
+ msg = "Approved {}".format(package.title)
+ addNotification(package.maintainers, current_user, msg, package.getDetailsURL(), package)
+ severity = AuditSeverity.NORMAL if current_user == package.author else AuditSeverity.EDITOR
+ addAuditLog(severity, current_user, msg, package.getDetailsURL(), package)
db.session.commit()
return redirect(package.getDetailsURL())
@@ -359,8 +366,9 @@ def remove(package):
package.soft_deleted = True
url = url_for("users.profile", username=package.author.username)
- addNotification(package.maintainers, current_user,
- "Deleted {}".format(package.title), url, package)
+ msg = "Deleted {}".format(package.title)
+ addNotification(package.maintainers, current_user, msg, url, package)
+ addAuditLog(AuditSeverity.EDITOR, current_user, msg, url)
db.session.commit()
flash("Deleted package", "success")
@@ -373,8 +381,10 @@ def remove(package):
package.approved = False
- addNotification(package.maintainers, current_user,
- "Unapproved {}".format(package.title), package.getDetailsURL(), package)
+ msg = "Unapproved {}".format(package.title)
+ addNotification(package.maintainers, current_user, msg, package.getDetailsURL(), package)
+ addAuditLog(AuditSeverity.EDITOR, current_user, msg, package.getDetailsURL(), package)
+
db.session.commit()
flash("Unapproved package", "success")
@@ -420,8 +430,10 @@ def edit_maintainers(package):
package.maintainers.extend(users)
package.maintainers.append(package.author)
- addNotification(package.author, current_user,
- "Edited {} maintainers".format(package.title), package.getDetailsURL(), package)
+ msg = "Edited {} maintainers".format(package.title)
+ addNotification(package.author, current_user, msg, package.getDetailsURL(), package)
+ severity = AuditSeverity.NORMAL if current_user == package.author else AuditSeverity.MODERATION
+ addAuditLog(severity, current_user, msg, package.getDetailsURL(), package)
db.session.commit()