From 50b860233b057d9228accba290810f6ebea5db2d Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 28 Jan 2024 21:51:31 +0000 Subject: [PATCH] Allow admin tools page to be used by editors This makes it easier to find certain tools --- app/blueprints/admin/admin.py | 7 +- app/templates/admin/list.html | 124 ++++++++++++++++++++++++++-------- app/templates/base.html | 14 +--- 3 files changed, 99 insertions(+), 46 deletions(-) diff --git a/app/blueprints/admin/admin.py b/app/blueprints/admin/admin.py index e2c50016..cd4232e7 100644 --- a/app/blueprints/admin/admin.py +++ b/app/blueprints/admin/admin.py @@ -28,9 +28,9 @@ from ...querybuilder import QueryBuilder @bp.route("/admin/", methods=["GET", "POST"]) -@rank_required(UserRank.ADMIN) +@rank_required(UserRank.EDITOR) def admin_page(): - if request.method == "POST": + if request.method == "POST" and current_user.rank.at_least(UserRank.ADMIN): action = request.form["action"] if action in actions: ret = actions[action]["func"]() @@ -40,8 +40,7 @@ def admin_page(): else: flash("Unknown action: " + action, "danger") - deleted_packages = Package.query.filter(Package.state == PackageState.DELETED).all() - return render_template("admin/list.html", deleted_packages=deleted_packages, actions=actions) + return render_template("admin/list.html", actions=actions) class SwitchUserForm(FlaskForm): diff --git a/app/templates/admin/list.html b/app/templates/admin/list.html index 565a4e3e..c541bcc4 100644 --- a/app/templates/admin/list.html +++ b/app/templates/admin/list.html @@ -5,41 +5,107 @@ {% endblock %} {% block content %} +

{{ self.title() }}

+
+

Users

+ +

Packages

+ + +

Types

+
+ {% if check_global_perm(current_user, "EDIT_TAGS") %} + + + Tag Editor + + {% endif %} + + {% if current_user.rank.at_least(current_user.rank.MODERATOR) %} + + + License Editor + + + + Version Editor + + {% endif %} + + {% if current_user.rank.at_least(current_user.rank.ADMIN) %} + + + Warning Editor + + {% endif %}
+ {% if current_user.rank.name == "ADMIN" %} +
+

Admin

+ +
+

Do action

-
-
-

Do action

- -
- -
- - -
-
+
+ +
+ + +
+
+
-
+ {% endif %}
{% endblock %} diff --git a/app/templates/base.html b/app/templates/base.html index 32916b9c..3aedb224 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -159,21 +159,9 @@ {{ _("Audit Log") }} - {% if current_user.rank == current_user.rank.ADMIN %} - - {% else %} - {% if current_user.rank == current_user.rank.MODERATOR %} - - {% endif %} - {% endif %} {% endif %} {% if current_user.rank.at_least(current_user.rank.EDITOR) %} - - {% endif %} - {% if check_global_perm(current_user, "EDIT_TAGS") %} - - {% elif check_global_perm(current_user, "CREATE_TAG") %} - + {% endif %}