aboutsummaryrefslogtreecommitdiffhomepage
path: root/apioforum/templates/view_thread.html
diff options
context:
space:
mode:
authorcitrons <citrons>2021-08-06 03:31:07 +0000
committercitrons <citrons>2021-08-06 03:31:07 +0000
commit5cf3eaebb1db20d61b88f044dfb2a34512aecd61 (patch)
tree945a270e59bb6d691e6f20686f2f9c8ec3d6e8b4 /apioforum/templates/view_thread.html
parent52c63cddb3f7860862af6a2185a728baf7593cc7 (diff)
parent74a992ca018a69cc1de6225a681ca17c19c74ffa (diff)
merge the things; poll permissions
Diffstat (limited to 'apioforum/templates/view_thread.html')
-rw-r--r--apioforum/templates/view_thread.html71
1 files changed, 68 insertions, 3 deletions
diff --git a/apioforum/templates/view_thread.html b/apioforum/templates/view_thread.html
index da8df74..132fd44 100644
--- a/apioforum/templates/view_thread.html
+++ b/apioforum/templates/view_thread.html
@@ -1,4 +1,4 @@
-{% from 'common.html' import disp_post,tag,thread_breadcrumb %}
+{% from 'common.html' import disp_post,tag,thread_breadcrumb,vote_meter %}
{% extends 'base.html' %}
{% block header %}
<h1>{%block title %}{{thread.title}}{% endblock %} <span class="thing-id">#{{thread.id}}</span></h1>
@@ -6,6 +6,15 @@
{% endblock %}
{%block content%}
+{% if poll %}
+<p>{{poll.title}}</p>
+<ol>
+ {%for opt in poll.options%}
+ <li value="{{opt.option_idx}}"><i>{{opt.text}}</i>: {{opt.num or 0}} votes</li>
+ {%endfor%}
+</ol>
+{{ vote_meter(poll) }}
+{% endif %}
<div class="thread-top-bar">
<span class="thread-top-bar-a">
{% if g.user == thread.creator or has_permission(thread.forum, g.user, "p_manage_threads") %}
@@ -25,14 +34,70 @@
<div class="posts">
{% for post in posts %}
- {{ disp_post(post, buttons=True, forum=thread.forum) }}
+ {% if votes[post.id] %}
+
+ {% set vote = votes[post.id] %}
+ {% set option_idx = vote.option_idx %}
+
+ {# this is bad but it's going to get refactored anyway #}
+ {% set footer %}
+ {% if vote.is_retraction %}
+ {% 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 %}
+ {% 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, forum=thread.forum, buttons=True, footer=footer) }}
+
+ {% else %}
+ {{ 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 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
+ on this poll, your previous vote will be changed</p>
+
+ <input type="radio" id="dontvote" name="poll" value="dontvote" checked>
+ <label for="dontvote">do not submit any vote at the moment</label>
+
+ {% if has_voted %}
+ <br>
+ <input type="radio" id="retractvote" name="poll" value="retractvote">
+ <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}}">#{{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 %}