Skip to content

Commit

Permalink
Add a role admin index
Browse files Browse the repository at this point in the history
  • Loading branch information
jellybob authored and marksteward committed May 7, 2024
1 parent 048899c commit a0b66a2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
16 changes: 16 additions & 0 deletions apps/volunteer/choose_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,22 @@ def choose_role():
return render_template("volunteer/choose_role.html", form=form)


@volunteer.route("/role_admin", methods=["GET"])
@v_user_required
def role_admin_index():
roles = []
if current_user.has_permission("admin") or current_user.has_permission("volunteer:manager"):
roles = Role.query.order_by("name").all()
else:
roles = [admin.role for admin in current_user.volunteer_admin_roles]

if len(roles) == 0:
flash("You're not an admin for any roles.")
redirect(url_for(".choose_role"))

return render_template("volunteer/role_admin_index.html", roles=roles)


@volunteer.route("/role/<int:role_id>", methods=["GET", "POST"])
@feature_flag("VOLUNTEERS_SIGNUP")
@v_user_required
Expand Down
3 changes: 3 additions & 0 deletions templates/volunteer/_nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
{% endif %}
{{ menuitem('Bar Training', '.bar_training') }}
{{ menuitem('Handbook', '.info') }}
{% if current_user.has_permission('volunteer:admin') or current_user.has_permission('volunteer:manager') or current_user.volunteer_admin_roles %}
{{ menuitem('Role Admin', '.role_admin_index')}}
{% endif %}
{% if current_user.has_permission('volunteer:admin') %}
{{ menuitem('Admin', 'volunteer_admin.index') }}
{% endif %}
Expand Down
17 changes: 17 additions & 0 deletions templates/volunteer/role_admin_index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% extends 'base.html' %}

{% block title %}
EMF Volunteer Role Admin
{% endblock %}

{% block body %}
{% include "volunteer/_nav.html" %}
<h2>Role Admin</h2>
<p>Select a role to administer it</p>
<ul>
{% for role in roles %}
<li><a href="{{url_for('.role_admin', role_id=role.id)}}">{{role.name}}</a></li>
{% endfor %}
</ul>
{% endblock %}

0 comments on commit a0b66a2

Please sign in to comment.