diff --git a/app/blueprints/admin/admin.py b/app/blueprints/admin/admin.py index cd8dd546..8345dfbf 100644 --- a/app/blueprints/admin/admin.py +++ b/app/blueprints/admin/admin.py @@ -95,3 +95,31 @@ def send_bulk_notification(): return redirect(url_for("admin.admin_page")) return render_template("admin/send_bulk_notification.html", form=form) + + +@bp.route("/admin/restore/", methods=["GET", "POST"]) +@rank_required(UserRank.EDITOR) +def restore(): + if request.method == "POST": + target = request.form["submit"] + if "Review" in target: + target = PackageState.READY_FOR_REVIEW + elif "Changes" in target: + target = PackageState.CHANGES_NEEDED + else: + target = PackageState.WIP + + package = Package.query.get(request.form["package"]) + if package is None: + flash("Unknown package", "danger") + else: + package.state = target + + addAuditLog(AuditSeverity.EDITOR, current_user, f"Restored package to state {target.value}", + package.getURL("packages.view"), package) + + db.session.commit() + return redirect(package.getURL("packages.view")) + + deleted_packages = Package.query.filter(Package.state==PackageState.DELETED).join(Package.author).order_by(db.asc(User.username), db.asc(Package.name)).all() + return render_template("admin/restore.html", deleted_packages=deleted_packages) \ No newline at end of file diff --git a/app/templates/admin/restore.html b/app/templates/admin/restore.html new file mode 100644 index 00000000..f310ffff --- /dev/null +++ b/app/templates/admin/restore.html @@ -0,0 +1,30 @@ +{% extends "base.html" %} + +{% block title %} + Restore +{% endblock %} + +{% block content %} +
+

Restore Package

+ +
+ +
+ +
+ + + +
+
+
+
+{% endblock %} diff --git a/app/templates/base.html b/app/templates/base.html index 8a9d2148..1841f36f 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -123,22 +123,27 @@ - {% if current_user.rank.atLeast(current_user.rank.MODERATOR) %} + {% if current_user.rank.atLeast(current_user.rank.EDITOR) or check_global_perm(current_user, "CREATE_TAG") %} + {% endif %} + {% if current_user.rank.atLeast(current_user.rank.MODERATOR) %} {% if current_user.rank == current_user.rank.ADMIN %} {% else %} - {% if check_global_perm(current_user, "EDIT_TAGS") %} - - {% elif check_global_perm(current_user, "CREATE_TAG") %} - - {% endif %} {% if current_user.rank == current_user.rank.MODERATOR %} {% endif %} {% endif %} {% endif %} + {% if current_user.rank.atLeast(current_user.rank.EDITOR) %} + + {% endif %} + {% if check_global_perm(current_user, "EDIT_TAGS") %} + + {% elif check_global_perm(current_user, "CREATE_TAG") %} + + {% endif %}