aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcitrons <citrons>2021-08-07 23:22:51 +0000
committercitrons <citrons>2021-08-07 23:22:51 +0000
commit09f38fd67bae05c7998ab9573d5842d02df247d8 (patch)
treef0e9c7ed7f915475e06b2942b15b4c9f17218233
parent2cbb238d80533cf06b1b6a7e1353843a0f583dea (diff)
one is now able to remove a role configuration
-rw-r--r--apioforum/forum.py6
-rw-r--r--apioforum/templates/edit_permissions.html10
2 files changed, 13 insertions, 3 deletions
diff --git a/apioforum/forum.py b/apioforum/forum.py
index bbc43fe..270b328 100644
--- a/apioforum/forum.py
+++ b/apioforum/forum.py
@@ -214,7 +214,11 @@ def edit_roles(forum):
if request.method == "POST":
for config in role_configs:
- if 'roleconfig_' + config['role'] in request.form:
+ if 'delete_' + config['role'] in request.form:
+ db.execute(
+ "DELETE FROM role_config WHERE forum = ? AND role = ?",
+ (forum['id'],config['role']))
+ elif 'roleconfig_' + config['role'] in request.form:
for p in role_permissions:
permission_setting =\
f"perm_{config['role']}_{p}" in request.form
diff --git a/apioforum/templates/edit_permissions.html b/apioforum/templates/edit_permissions.html
index f91c710..c92c9a9 100644
--- a/apioforum/templates/edit_permissions.html
+++ b/apioforum/templates/edit_permissions.html
@@ -16,7 +16,7 @@
{% for role_config in role_configs %}
<fieldset>
- <legend id="config_{{role_config.role}}">{{role_config.role}}</legend>
+ <legend id="config_{{role_config.role}}">{{role_config.role}}</legend>
{% macro perm(p, description, tooltip) %}
<input
type="checkbox"
@@ -46,11 +46,17 @@
{{perm("p_create_subforum","create subforæ",
"allow users with the role to create subforæ in this forum. " +
"they will automatically become a bureaucrat in this subforum.")}}
- <input type="hidden" name="roleconfig_{{role_config.role}}" value="present"/>
{% if role_config.role != "other" %}
{{perm("p_approve","approve others",
"allow users with the role to assign the 'approved' role to those with the 'other' role")}}
{% endif %}
+ <input type="hidden" name="roleconfig_{{role_config.role}}" value="present"/>
+
+ {% if forum.id != 1 or role_config.role != "other" %}
+ <hr/>
+ <input type="checkbox" name="delete_{{role_config.role}}" id="delete_{{role_config.role}}"/>
+ <label for="delete_{{role_config.role}}">remove</label>
+ {% endif %}
</fieldset>
{% endfor %}
{% if role_configs %}