aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--apioforum/forum.py15
-rw-r--r--apioforum/static/style.css3
-rw-r--r--apioforum/templates/role_assignment.html31
3 files changed, 43 insertions, 6 deletions
diff --git a/apioforum/forum.py b/apioforum/forum.py
index c0c0ba4..9d4a3cd 100644
--- a/apioforum/forum.py
+++ b/apioforum/forum.py
@@ -377,7 +377,18 @@ def view_user_role(forum):
return redirect(url_for( 'forum.edit_user_role',
username=request.form['user'],forum_id=forum['id']))
else:
- return render_template("role_assignment.html",forum=forum)
+ db = get_db()
+ assignments = db.execute("SELECT * FROM role_assignments WHERE forum = ?;",(forum['id'],)).fetchall()
+ if is_bureaucrat(forum['id'], g.user):
+ roles = get_forum_roles(forum['id'])
+ roles.remove("other")
+ roles.add("bureaucrat")
+ else:
+ roles = ["approved"]
+ return render_template("role_assignment.html",
+ forum=forum,
+ forum_roles=roles,
+ role_assignments=assignments)
@forum_route("role/<username>",methods=["GET","POST"])
@requires_permission("p_approve")
@@ -407,7 +418,7 @@ def edit_user_role(forum, username):
(username,role,forum['id']))
db.commit()
flash("role assigned assignedly")
- return redirect(url_for('forum.view_forum',forum_id=forum['id']))
+ return redirect(url_for('forum.view_user_role',forum_id=forum['id']))
else:
user = db.execute("SELECT * FROM users WHERE username = ?;",(username,)).fetchone()
if user == None:
diff --git a/apioforum/static/style.css b/apioforum/static/style.css
index 2ca0e51..feaa814 100644
--- a/apioforum/static/style.css
+++ b/apioforum/static/style.css
@@ -362,6 +362,9 @@ fieldset { margin-bottom: 15px; }
.role-input, .name-input { width: 12ch; }
+.role-list { margin: 20px }
+.role-list form { display: inline; margin: 20px }
+
.thing-id { color: var(--gray); font-size: smaller; font-weight: normal; }
.breadcrumbs {
diff --git a/apioforum/templates/role_assignment.html b/apioforum/templates/role_assignment.html
index 8309506..2944fe1 100644
--- a/apioforum/templates/role_assignment.html
+++ b/apioforum/templates/role_assignment.html
@@ -1,6 +1,6 @@
{% extends 'base.html' %}
{% from 'common.html' import ab %}
-{% block header %}<h1>{% block title %}configure user role in '{{forum.name}}'{% endblock %}</h1>{% endblock %}
+{% block header %}<h1>{% block title %}configure user roles in '{{forum.name}}'{% endblock %}</h1>{% endblock %}
{% block content %}
<p>
each user has a role in the forum.
@@ -18,7 +18,7 @@
<form method="post" action="{{url_for('forum.view_user_role',forum_id=forum.id)}}">
<label for="user">role settings for user: </label>
- <input type="text" class="name-input" id="user" name="user" value="{{user}}"/>
+ <input type="text" class="name-input" id="user" name="user" value="{{user}}" required/>
<input type="submit" value="view"/>
</form>
@@ -45,12 +45,35 @@
<p>you do not have permission to change the role of this user</p>
{% endif %}
</form>
-{% endif %}
{% if can_change %}<p>confirm changes?</p>{% endif %}
<p>
{% if can_change %}<input type="submit" value="confirm" form="role-form">{% endif %}
- <a href="{{url_for('forum.view_forum',forum_id=forum.id)}}">cancel</a>
+ <a href="{{url_for('forum.view_user_role',forum_id=forum.id)}}">cancel</a>
</p>
+{% else %}
+<p><a href="{{url_for('forum.view_forum',forum_id=forum.id)}}">back</a></p>
+{% if role_assignments %}<h2>assigned roles</h2>{% endif %}
+<table class="role-list">
+ {% for ass in role_assignments %}
+ {% set can_change = ass.role == "other" or is_bureaucrat(forum.id, g.user) %}
+ <tr>
+ <td>{{disp_user(ass.user)}}
+ <td><form method="post" action="{{url_for('forum.edit_user_role',forum_id=forum.id,username=ass.user)}}">
+ <select name="role" autocomplete="off" {% if not can_change %}disabled{% endif%}>
+ <option value="">(no assigned role)</option>
+ {% for role in forum_roles %}
+ <option value="{{role}}"
+ {% if role == ass.role %}selected{% endif %}>
+ {{role}}
+ </option>
+ {% endfor %}
+ </select>
+ <input type="submit" value="change" {% if not can_change %}disabled{% endif%}/>
+ </form>
+ </tr>
+ {% endfor %}
+</ul>
+{% endif %}
{% endblock %}