aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app.py14
-rw-r--r--static/styles.css4
-rw-r--r--templates/poll_vote_list.html.j23
-rw-r--r--templates/poll_vote_table.html.j23
4 files changed, 22 insertions, 2 deletions
diff --git a/app.py b/app.py
index 8ca7c44..021cec7 100644
--- a/app.py
+++ b/app.py
@@ -163,11 +163,25 @@ def poll(id):
voter_names = list(voter_names_set)
voter_names.sort()
+ most_voted_choice_ids: set[str] = set()
+ most_voted_value = 0
+ for choice in poll.choices:
+ n_votes = 0
+ for vote in choice.votes:
+ n_votes += vote.value
+
+ if n_votes > most_voted_value:
+ most_voted_choice_ids = { choice.id }
+ most_voted_value = n_votes
+ elif n_votes == most_voted_value:
+ most_voted_choice_ids.add(choice.id)
+
resp = make_response(
render_template("poll.html.j2",
poll=poll,
selections=selections,
choices=poll.choices,
+ most_voted_choice_ids=most_voted_choice_ids,
prefill_voter_name=prefill_voter_name,
voter_names=voter_names,
managed_voter_names=managed_voter_names,
diff --git a/static/styles.css b/static/styles.css
index 770bd87..a3d3d3d 100644
--- a/static/styles.css
+++ b/static/styles.css
@@ -194,3 +194,7 @@ input[type="submit"].delete-voter-btn {
background: none;
padding: 0;
}
+
+.most-voted {
+ background-color: #ffcd0455 !important;
+}
diff --git a/templates/poll_vote_list.html.j2 b/templates/poll_vote_list.html.j2
index 47a682f..c62c102 100644
--- a/templates/poll_vote_list.html.j2
+++ b/templates/poll_vote_list.html.j2
@@ -1,13 +1,14 @@
<form action="/poll/{{ poll.id }}/vote" method="post">
<div class="vote-list">
{% for choice in choices %}
- <div>
+ <div {% if choice.id in most_voted_choice_ids %}class="most-voted"{% endif %}>
<label for="choice_{{ choice.id }}">
<input type="checkbox" name="choice_{{ choice.id }}" id="choice_{{ choice.id }}">
<strong>
{% include "poll_choice_datetime_range.html.j2" %}
</strong>
<span>
+ {% if choice.id in most_voted_choice_ids %}👑{% endif %}
<i>{{ choice.votes_with_value(1) | length }}&nbsp;votes</i>
</span>
<div>
diff --git a/templates/poll_vote_table.html.j2 b/templates/poll_vote_table.html.j2
index 440f2b7..a93ebfa 100644
--- a/templates/poll_vote_table.html.j2
+++ b/templates/poll_vote_table.html.j2
@@ -2,9 +2,10 @@
<tr>
<th></th>
{% for choice in choices %}
- <th>
+ <th {% if choice.id in most_voted_choice_ids %}class="most-voted"{% endif %}>
{% include "poll_choice_datetime_range.html.j2" %}
<span>
+ {% if choice.id in most_voted_choice_ids %}👑{% endif %}
<i>{{ choice.votes_with_value(1) | length }} votes</i>
</span>
</th>