diff options
author | ubq323 <ubq323> | 2021-08-11 23:58:39 +0000 |
---|---|---|
committer | ubq323 <ubq323> | 2021-08-11 23:58:39 +0000 |
commit | 17357a3fb5cf603ff79daad644f4a4c0fbe42150 (patch) | |
tree | 4235c00596258027cecf30abaa90f7fefa0acb58 /apioforum/templates | |
parent | 74a992ca018a69cc1de6225a681ca17c19c74ffa (diff) | |
parent | 2d812c9c01bdc94e56500c0c0ffe187117e7696a (diff) |
deploying deployment of bureaucracy
Diffstat (limited to 'apioforum/templates')
-rw-r--r-- | apioforum/templates/common.html | 53 | ||||
-rw-r--r-- | apioforum/templates/config_thread.html | 5 | ||||
-rw-r--r-- | apioforum/templates/delete_thread.html | 18 | ||||
-rw-r--r-- | apioforum/templates/edit_forum.html | 25 | ||||
-rw-r--r-- | apioforum/templates/edit_permissions.html | 94 | ||||
-rw-r--r-- | apioforum/templates/role_assignment.html | 56 | ||||
-rw-r--r-- | apioforum/templates/view_forum.html | 79 | ||||
-rw-r--r-- | apioforum/templates/view_thread.html | 33 | ||||
-rw-r--r-- | apioforum/templates/view_unlisted.html | 24 |
9 files changed, 345 insertions, 42 deletions
diff --git a/apioforum/templates/common.html b/apioforum/templates/common.html index dfbd934..f6b6f29 100644 --- a/apioforum/templates/common.html +++ b/apioforum/templates/common.html @@ -6,33 +6,58 @@ {{url_for('thread.view_thread', thread_id=post.thread)}}#post_{{post.id}} {%- endmacro %} -{% macro disp_post(post, buttons=False, footer=None) %} -<div class="post" id="post_{{post.id}}"> +{% macro disp_post(post, buttons=False, forum=None, footer=None) %} +<div class="post {% if post.deleted %}deleted-post{% endif %}" id="post_{{post.id}}"> <div class="post-heading"> <span class="post-heading-a"> - {{disp_user(post.author)}} + {% if not post.deleted %} + {{disp_user(post.author)}} + {% else %} + <span class="username">big brother</span> + {% endif %} + + {% if forum != None %} + {% set role = get_user_role(forum, post.author) %} + {% if post.deleted %} + <span class="user-role"> + (bureaucrat) + </span> + {% elif role != "other" %} + <span class="user-role"> + ({{ role }}) + </span> + {% endif %} + {% endif %} + {{ts(post.created)}} + {% if post.edited %} (edited {{ts(post.updated)}}) {% endif %} </span> <span class="post-heading-b"> - {% if buttons %} - {% if post.author == g.user %} - <a class="actionbutton" - href="{{url_for('thread.edit_post',post_id=post.id)}}">edit</a> - <a class="actionbutton" - href="{{url_for('thread.delete_post',post_id=post.id)}}">delete</a> - {% endif %} + {% if buttons and not post.deleted %} + {% if post.author == g.user %} + <a class="actionbutton" + href="{{url_for('thread.edit_post',post_id=post.id)}}">edit</a> + {% endif %} + {% if post.author == g.user or (forum and has_permission(forum, g.user, "p_delete_posts")) %} + <a class="actionbutton" + href="{{url_for('thread.delete_post',post_id=post.id)}}">delete</a> + {% endif %} <a class="actionbutton" href="{{url_for('thread.view_post',post_id=post.id)}}">src</a> {% endif %} - <a class="post-anchor-link" href="{{post_url(post)}}">#{{post.id}}</a> + <a class="post-anchor-link" href="{{post_url(post)}}">#{{post.id}}</a> </span> </div> <div class="post-content md"> - {{ post.content|md|safe }} + {% if not post.deleted %} + {{ post.content|md|safe }} + {% else %} + this post never existed. + {% endif %} </div> {% if footer %} <div class="post-footer"> @@ -50,6 +75,10 @@ <span class="tag" style="color: {{the_tag.text_colour}}; background-color: {{the_tag.bg_colour}}">{{the_tag.name}}</span> {%- endmacro %} +{% macro ab(name,href) -%} +<a class="actionbutton" href="{{href}}">{{name}}</a> +{%- endmacro %} + {% macro breadcrumb() %} <nav aria-label="Breadcrumb"> <ol class="breadcrumbs"> diff --git a/apioforum/templates/config_thread.html b/apioforum/templates/config_thread.html index 2c9804e..0795ccc 100644 --- a/apioforum/templates/config_thread.html +++ b/apioforum/templates/config_thread.html @@ -29,6 +29,7 @@ <a href="{{url_for('thread.view_thread',thread_id=thread.id)}}">cancel</a> </form> +{% if has_permission(thread.forum, g.user, "p_create_polls") %} {% if thread.poll is none %} <h2>create poll</h2> <form method="post" action="{{url_for('thread.create_poll',thread_id=thread.id)}}"> @@ -37,7 +38,7 @@ <label for="polltitle">question title</label> <input type="title" id="polltitle" name="polltitle"> <br> - <label for="polloptions">potential options (one per line)</label> + <label for="polloptions">options (one per line)</label> <textarea name="polloptions" id="polloptions"></textarea> </fieldset> <p>important: once a poll is created, you will not be able to modify it except to delete it entirely</p> @@ -49,7 +50,7 @@ <form action="{{url_for('thread.delete_poll',thread_id=thread.id)}}" method="post"> <input type="submit" value="confirm: delete poll"> </form> - +{% endif %} {% endif %} {% endblock %} diff --git a/apioforum/templates/delete_thread.html b/apioforum/templates/delete_thread.html new file mode 100644 index 0000000..aaf1de3 --- /dev/null +++ b/apioforum/templates/delete_thread.html @@ -0,0 +1,18 @@ +{% from 'common.html' import ts %} +{% extends 'base.html' %} +{% block header %} +<h1>{% block title %}delete thread '{{thread.title}}'{% endblock %}</h1> +{% endblock %} + +{% block content %} + +<form method="post"> +<p>deleting thread created {{ts(thread.created)}} ago with {{post_count}} posts</p> +{% if post_count > 50 %} +<p class="warning">thread contains more than 50 posts!</p> +{% endif %} +<p>confirm delete?</p> +<input type="submit" value="delete"> +<a href="{{url_for('thread.view_thread',thread_id=thread.id)}}">cancel</a> +</form> +{% endblock %} diff --git a/apioforum/templates/edit_forum.html b/apioforum/templates/edit_forum.html new file mode 100644 index 0000000..f165676 --- /dev/null +++ b/apioforum/templates/edit_forum.html @@ -0,0 +1,25 @@ +{% extends 'base.html' %} +{% block header %} +<h1>{% block title %}{%if create %}create{% else %}edit{%endif%} forum{% endblock %}</h1> +{% endblock %} + +{% block content %} +<form method="POST"> + <label for="name">forum name</label> + <input name="name" id="name" value="{{name}}" placeholder="apioforum" required maxlength="100"/> + <br> + <label for="description">forum description (markdown enabled)</label> + <textarea + name="description" + id="description" + class="forum-desc-box" + placeholder="this is a forum for discussing bees" + maxlength="6000" + required + >{{description}}</textarea> + <p> + <input type="submit" value="confirm"> + <a href="{{cancel_link}}">cancel</a> + </p> +</form> +{% endblock %} diff --git a/apioforum/templates/edit_permissions.html b/apioforum/templates/edit_permissions.html new file mode 100644 index 0000000..59c9093 --- /dev/null +++ b/apioforum/templates/edit_permissions.html @@ -0,0 +1,94 @@ +{% extends 'base.html' %} +{% block header %}<h1>{% block title %}role permissions for '{{forum.name}}'{% endblock %}</h1>{% endblock %} +{% block content %} +<p> + each user has a role in the forum. + a user may be assigned a role in the forum. + otherwise, the user's role is the same as the parent forum. + everyone's role is "other" by default. +</p> +<p> + here, a set of permissions may be associated with any role. + if a role does not have any permissions configured for this forum, + the permissions set for the role in closest ancestor forum are used. +</p> +<form method="post" id="role_config"> + +{% for role_config in role_configs %} + <fieldset> + <legend id="config_{{role_config.role}}">{{role_config.role}}</legend> + {% macro perm(p, description, tooltip) %} + <input + type="checkbox" + id="perm_{{role_config.role}}_{{p}}" + name="perm_{{role_config.role}}_{{p}}" + {% if role_config[p] %}checked{% endif %} + /> + <label for="perm_{{role_config.role}}_{{p}}" title="{{tooltip}}"> + {{- description -}} + </label> + <br/> + {% endmacro %} + {{perm("p_view_forum","view the forum", + "allow users with the role to see the forum in listings and view information about it")}} + {{perm("p_create_threads","create threads", + "allow users with the role to create a thread in the forum")}} + {{perm("p_reply_threads","reply to threads", + "allow users with the role to create a post within a thread")}} + {{perm("p_view_threads","view threads", + "allow users with the role to view threads in the forum")}} + {{perm("p_manage_threads","configure others' threads", + "allow users with the role to modify the title/tags for others' threads or lock it to prevent new posts")}} + {{perm("p_delete_posts","delete others' posts and threads", + "allow users with the role to delete others' posts and threads")}} + {{perm("p_create_polls","create polls", + "allow users with the role to add a poll to a thread")}} + {{perm("p_vote","vote", + "allow users with the role to vote in polls")}} + {{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.")}} + {% 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 %} + <p>confirm changes?</p> + <p> + <input type="submit" value="confirm"> + <a href="{{url_for('forum.view_forum',forum_id=forum.id)}}">cancel</a> + </p> +{% endif %} +</form> + + +<fieldset> + <legend>add role</legend> + <ul> + {% for role in other_roles %} + <li>{{role}} + <form action="{{url_for('forum.add_role',forum_id=forum.id)}}" method="POST" style="display:inline"> + <input type="hidden" value="{{role}}" name="role" /> + <input type="submit" value="add" /> + </form> + </li> + {% endfor %} + <li> + <form action="{{url_for('forum.add_role',forum_id=forum.id)}}" method="POST" style="display:inline"> + <input type="text" name="role" class="role-input" placeholder="role name" maxlength="32"/> + <input type="submit" value="add" /> + </form> + </li> + </ul> +</fieldset> + +{% endblock %} diff --git a/apioforum/templates/role_assignment.html b/apioforum/templates/role_assignment.html new file mode 100644 index 0000000..8309506 --- /dev/null +++ b/apioforum/templates/role_assignment.html @@ -0,0 +1,56 @@ +{% extends 'base.html' %} +{% from 'common.html' import ab %} +{% block header %}<h1>{% block title %}configure user role in '{{forum.name}}'{% endblock %}</h1>{% endblock %} +{% block content %} +<p> + each user has a role in the forum. + here, a user may be assigned a role in the forum. + otherwise, the user's role is the same as the parent forum. + everyone's role is "other" by default. +</p> +{% if not is_bureaucrat(forum.id, g.user) %} + <p> + you are only allowed to approve members in this forum. + </p> +{% endif %} + +{# <p>{{ab("role assignment list",url_for("forum.role_list_select",forum_id=forum.id))}}</p> #} + +<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="submit" value="view"/> +</form> + +{% set can_change = not invalid_user and user %} +{% if invalid_user %} + <p>requested user does not exist.</p> +{% elif user %} +<hr/> +<form method="post" id="role-form"> + <p>{{user}}'s role in this forum is "{{role}}"</p> + {% set can_change = role == "other" or is_bureaucrat(forum.id, g.user) %} + {% if can_change %} + <label for="role">assigned role: </label> + <select name="role" id="role" autocomplete="off"> + <option value="" {% if not assigned_role %}selected{% endif %}>(no assigned role)</option> + {% for role in forum_roles %} + <option value="{{role}}" + {% if role == assigned_role %}selected{% endif %}> + {{role}} + </option> + {% endfor %} + </select> + {% else %} + <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> +</p> + +{% endblock %} diff --git a/apioforum/templates/view_forum.html b/apioforum/templates/view_forum.html index 475fdc2..0eada1a 100644 --- a/apioforum/templates/view_forum.html +++ b/apioforum/templates/view_forum.html @@ -1,25 +1,56 @@ {% extends 'base.html' %} -{% from 'common.html' import ts, tag, disp_user, post_url, forum_breadcrumb, vote_meter %} +{% from 'common.html' import ts, tag, disp_user, post_url, forum_breadcrumb, ab, vote_meter %} {% block header %} -<h1>{% block title %}{{forum.name}}{%endblock%}</h1> +<h1>{% block title %}{{forum.name}}{% endblock %} <span class="thing-id">#{{forum.id}}</span></h1> {% if forum.id != 1 %} {{ forum_breadcrumb(forum) }} {% endif %} {%endblock%} {%block content%} -{% if forum.description %} -{{forum.description|md|safe}} -{% endif %} -<p class="avail_tags">available tags: -{% for the_tag in avail_tags %} -{{tag(the_tag)}} -{% else %} -<em>(none available)</em> -{% endfor %} +{{forum.description|md|safe}} + +<hr/> +<div class="forum-info"> + {% if bureaucrats|length > 0 %} + <p> + bureaucrats in this forum: + {% for b in bureaucrats %} + {{disp_user(b)}} + {% endfor %} + </p> + {% endif %} + + {% set role = get_user_role(forum.id, g.user) %} + {% if role != "other" %} + <p>your role in this forum: {{role}}</p> + {% endif %} + + <p>available tags: + {% for the_tag in avail_tags %} + {{tag(the_tag)}} + {% else %} + <em>(none available)</em> + {% endfor %} + </p> +</div> + +<p> + {% if is_bureaucrat(forum.id, g.user) %} + {{ab("forum settings",url_for('forum.edit_forum',forum_id=forum.id))}} + {{ab("role/permission settings",url_for('forum.edit_roles',forum_id=forum.id))}} + {{ab("assign roles",url_for('forum.view_user_role',forum_id=forum.id))}} + {% endif %} + {% if has_permission(forum.id, g.user, "p_create_subforum") %} + {{ab("create subforum",url_for('forum.create_forum',forum_id=forum.id))}} + {% endif %} + {% if not is_bureaucrat(forum.id, g.user) and has_permission(forum.id, g.user, "p_approve") %} + {{ab("approve users",url_for('forum.view_user_role',forum_id=forum.id))}} + {% endif %} +</p> {% if subforums %} -<h2>subforae</h2> +<h2>subforæ</h2> <div class="forum-list"> {% for subforum in subforums %} <div class="listing"> @@ -44,12 +75,15 @@ <h2>threads</h2> <p> -{% if g.user %} +{% if has_permission(forum.id, g.user, "p_create_threads") %} <a class="actionbutton" href="{{url_for('forum.create_thread',forum_id=forum.id)}}">create new thread</a> -{% else %} +{% elif has_permission(forum.id, g.user, "p_create_threads", login_required=False) %} please log in to create a new thread +{% else %} +you do not have permission to create threads in this forum {% endif %} -</p> + +{% if has_permission(forum.id, g.user, "p_view_threads", login_required=False) %} <div class="thread-list"> {%for thread in threads%} <div class="listing"> @@ -71,7 +105,7 @@ please log in to create a new thread {{ ts(thread.created) }} </div> </div> - {#{% if thread.mrp_id %}#} + {% if not thread.mrp_deleted %} <div class="listing-caption"> {{ disp_user(thread.mrp_author) }} <span class="thread-preview-ts"> @@ -83,7 +117,14 @@ please log in to create a new thread </a> </span> </div> - {#{% endif %}#} + {% else %} + <div class="listing-caption"> + <a class="thread-preview-post" + href="{{url_for('thread.view_thread',thread_id=thread.id)}}#post_{{thread.mrp_id}}"> + latest post + </a> + </div> + {% endif %} {% if thread_polls[thread.id] %} <div class="thread-vote-summary"> {{ vote_meter(thread_polls[thread.id]) }} @@ -92,5 +133,7 @@ please log in to create a new thread </div> {%endfor%} </div> -</main> +{% else %} +<p>you do not have permission to view threads in this forum</p> +{% endif %} {%endblock%} diff --git a/apioforum/templates/view_thread.html b/apioforum/templates/view_thread.html index 29914e8..132fd44 100644 --- a/apioforum/templates/view_thread.html +++ b/apioforum/templates/view_thread.html @@ -1,7 +1,7 @@ {% from 'common.html' import disp_post,tag,thread_breadcrumb,vote_meter %} {% extends 'base.html' %} {% block header %} -<h1>{%block title %}{{thread.title}}{% endblock %}</h1> +<h1>{%block title %}{{thread.title}}{% endblock %} <span class="thing-id">#{{thread.id}}</span></h1> {{ thread_breadcrumb(thread) }} {% endblock %} @@ -17,9 +17,12 @@ {% endif %} <div class="thread-top-bar"> <span class="thread-top-bar-a"> - {% if g.user == thread.creator %} + {% if g.user == thread.creator or has_permission(thread.forum, g.user, "p_manage_threads") %} <a class="actionbutton" href="{{url_for('thread.config_thread',thread_id=thread.id)}}">configure thread</a> {% endif %} + {% if has_permission(thread.forum, g.user, "p_delete_posts") %} + <a class="actionbutton" href="{{url_for('thread.delete_thread',thread_id=thread.id)}}">delete thread</a> + {% endif %} </span> <span class="thread-top-bar-b"> @@ -39,29 +42,37 @@ {# this is bad but it's going to get refactored anyway #} {% set footer %} {% if vote.is_retraction %} - {{post.author}} retracted their vote + {% if not post.deleted %} + {{post.author}} retracted their vote + {% else %} + this post retracted a vote + {% endif %} {% else %} {% set option = poll.options[option_idx-1] %} {% if vote.current %} {{post.author}} votes for {{option_idx}}: {{option.text}} {% else %} - {{post.author}} voted for {{option_idx}}: {{option.text}}, but later changed their vote + {% if not post.deleted %} + {{post.author}} voted for {{option_idx}}: {{option.text}}, but later changed their vote + {% else %} + this post presented a vote that was later changed + {% endif %} {% endif %} {% endif %} {% endset %} - {{ disp_post(post, buttons=True, footer=footer) }} + {{ disp_post(post, forum=thread.forum, buttons=True, footer=footer) }} {% else %} - {{ disp_post(post, buttons=True) }} + {{ disp_post(post, forum=thread.forum, buttons=True) }} {% endif %} {% endfor %} </div> -{% if g.user %} +{% if g.user and has_permission(thread.forum, g.user, "p_reply_threads") %} <form class="new-post" action="{{url_for('thread.create_post',thread_id=thread.id)}}" method="POST"> <textarea class="new-post-box" placeholder="your post here..." name="content"></textarea> - {% if poll %} + {% if poll and has_permission(thread.forum, g.user, "p_vote") %} <fieldset> <legend>poll: {{poll.title}}</legend> <p>if you want, you can submit a vote along with this post. if you have previously voted @@ -73,18 +84,20 @@ {% if has_voted %} <br> <input type="radio" id="retractvote" name="poll" value="retractvote"> - <label for="retractvote">retract my vote, and go back to having no vote on this poll</label> + <label for="retractvote">clear current vote</label> {% endif %} {% for opt in poll.options %} <br> <input type="radio" id="option_{{opt.option_idx}}" name="poll" value="{{opt.option_idx}}"> - <label for="option_{{opt.option_idx}}">submit a vote for #{{opt.option_idx}} - {{opt.text}}</label> + <label for="option_{{opt.option_idx}}">#{{opt.option_idx}} - {{opt.text}}</label> {% endfor %} </fieldset> {% endif %} <input type="submit" value="yes"> </form> +{% elif g.user %} +<p>you do not have permission to reply to this thread</p> {% else %} <p>please log in to reply to this thread</p> {% endif %} diff --git a/apioforum/templates/view_unlisted.html b/apioforum/templates/view_unlisted.html new file mode 100644 index 0000000..c0fd074 --- /dev/null +++ b/apioforum/templates/view_unlisted.html @@ -0,0 +1,24 @@ +{% extends 'base.html' %} +{% from 'common.html' import forum_breadcrumb %} +{% block header %} +<h1>{% block title %}unlisted subforæ in '{{forum.name}}'{% endblock %}</h1> +{% if forum.id != 1 %} + {{ forum_breadcrumb(forum) }} +{% endif %} +{% endblock %} + +{% block content %} +<form method="POST"> + {% if unlisted %} + <ul> + {% for f in unlisted %} + <li> + <a href="{{url_for('forum.view_forum',forum_id=f.id)}}">{{f.name}}</a> + </li> + {% endfor %} + </ul> + {% else %} + <p>there are no unlisted subforæ in '{{forum.name}}'</p> + {% endif %} +</form> +{% endblock %} |