diff options
author | citrons <citrons> | 2021-07-11 02:48:39 +0000 |
---|---|---|
committer | citrons <citrons> | 2021-07-11 02:48:39 +0000 |
commit | 8d2d7a54ee496224061d03bd81432688b14c1eb3 (patch) | |
tree | 13a10d475609a5b513443ba898e63bd147effb75 /apioforum/templates/view_thread.html | |
parent | 9c375cff4dc60ef1ff0c512f6da028129430e377 (diff) | |
parent | 2eae97d6a08da4b832ccc69ce66bd15009001737 (diff) |
polls are functional now
Diffstat (limited to 'apioforum/templates/view_thread.html')
-rw-r--r-- | apioforum/templates/view_thread.html | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/apioforum/templates/view_thread.html b/apioforum/templates/view_thread.html index fb62880..7bf253d 100644 --- a/apioforum/templates/view_thread.html +++ b/apioforum/templates/view_thread.html @@ -5,6 +5,14 @@ {% endblock %} {%block content%} +{% if poll %} +<p>{{poll.title}}</p> +<ul> + {%for opt in poll.options%} + <li>#{{opt.option_idx}} - {{opt.text}} - {{opt.num or 0}}</li> + {%endfor%} +</ul> +{% endif %} <div class="thread-top-bar"> <span class="thread-top-bar-a"> {% if g.user == thread.creator %} @@ -21,12 +29,58 @@ <div class="posts"> {% for post in posts %} - {{ disp_post(post, True) }} + {% 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 %} + {{post.author}} retracted their vote + {% 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 + {% endif %} + {% endif %} + + {% endset %} + + {{ disp_post(post, buttons=True, footer=footer) }} + + {% else %} + {{ disp_post(post, buttons=True) }} + {% endif %} {% endfor %} </div> {% if g.user %} <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 %} + <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">retract my vote, and go back to having no vote on this poll</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> + {% endfor %} + </fieldset> + {% endif %} <input type="submit" value="yes"> </form> {% else %} |