Add reason to package removal

This commit is contained in:
rubenwardy 2022-01-09 21:12:29 +00:00
parent db14b3f4ef
commit 34ccd76b0c
2 changed files with 9 additions and 2 deletions

View File

@ -408,6 +408,8 @@ def remove(package):
return render_template("packages/remove.html", package=package,
tabs=get_package_tabs(current_user, package), current_tab="remove")
reason = request.form.get("reason") or "?"
if "delete" in request.form:
if not package.checkPerm(current_user, Permission.DELETE_PACKAGE):
flash(gettext("You don't have permission to do that."), "danger")
@ -416,7 +418,7 @@ def remove(package):
package.state = PackageState.DELETED
url = url_for("users.profile", username=package.author.username)
msg = "Deleted {}".format(package.title)
msg = "Deleted {}, reason={}".format(package.title, reason)
addNotification(package.maintainers, current_user, NotificationType.PACKAGE_EDIT, msg, url, package)
addAuditLog(AuditSeverity.EDITOR, current_user, msg, url)
db.session.commit()
@ -431,7 +433,7 @@ def remove(package):
package.state = PackageState.WIP
msg = "Unapproved {}".format(package.title)
msg = "Unapproved {}, reason={}".format(package.title, reason)
addNotification(package.maintainers, current_user, NotificationType.PACKAGE_APPROVAL, msg, package.getURL("packages.view"), package)
addAuditLog(AuditSeverity.EDITOR, current_user, msg, package.getURL("packages.view"), package)

View File

@ -23,6 +23,11 @@ Remove {{ package.title }}
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<div class="form-group">
<label for="reason">Reason</label>
<input id="reason" class="form-control" type="text" name="reason" required minlength="5">
</div>
<a class="btn btn-secondary float-right" href="{{ package.getURL("packages.view") }}">{{ _("Cancel") }}</a>
<input type="submit" name="delete" value="Remove" class="btn btn-danger mr-2" />