diff options
author | ubq323 <ubq323> | 2021-06-26 01:05:28 +0000 |
---|---|---|
committer | ubq323 <ubq323> | 2021-06-26 01:05:28 +0000 |
commit | a1660cad33f03828e2c74d8f083ad6490ea0da7f (patch) | |
tree | 3237418f6317d0c9bbe765c172d47ef76304e9e6 /apioforum/templates | |
parent | ccb0394a52050f21701c856239f999ede529f71b (diff) |
displaying of votes on posts
Diffstat (limited to 'apioforum/templates')
-rw-r--r-- | apioforum/templates/common.html | 7 | ||||
-rw-r--r-- | apioforum/templates/view_thread.html | 20 |
2 files changed, 25 insertions, 2 deletions
diff --git a/apioforum/templates/common.html b/apioforum/templates/common.html index 8fcf5fe..3321085 100644 --- a/apioforum/templates/common.html +++ b/apioforum/templates/common.html @@ -6,7 +6,7 @@ {{url_for('thread.view_thread', thread_id=post.thread)}}#post_{{post.id}} {%- endmacro %} -{% macro disp_post(post, buttons=False) %} +{% macro disp_post(post, buttons=False, footer=None) %} <div class="post" id="post_{{post.id}}"> <div class="post-heading"> <span class="post-heading-a"> @@ -34,6 +34,11 @@ <div class="post-content md"> {{ post.content|md|safe }} </div> + {% if footer %} + <div class="post-footer"> + {{ footer }} + </div> + {% endif %} </div> {% endmacro %} diff --git a/apioforum/templates/view_thread.html b/apioforum/templates/view_thread.html index d45b36b..513ee59 100644 --- a/apioforum/templates/view_thread.html +++ b/apioforum/templates/view_thread.html @@ -29,7 +29,25 @@ <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 %} + {% set option = poll.options[option_idx-1] %} + + {% set footer %} + {% 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 %} + {% endset %} + + {{ disp_post(post, buttons=True, footer=footer) }} + + {% else %} + {{ disp_post(post, buttons=True) }} + {% endif %} {% endfor %} </div> {% if g.user %} |