From 3620ac2671651eb096e49845e2ef500918e90d2a Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Thu, 29 Feb 2024 22:04:55 +0200 Subject: Fix list view voters, change font --- db.py | 8 ++++++++ static/styles.css | 18 ++++++++++++++++-- templates/manage.html.j2 | 1 + templates/poll_vote_list.html.j2 | 6 ++++-- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/db.py b/db.py index 57b54e3..e94c2a7 100644 --- a/db.py +++ b/db.py @@ -83,6 +83,9 @@ class Choice: return self.start_datetime.date() == self.end_datetime.date() \ and self.start_datetime.time() == self.end_datetime.time() + def votes_with_value(self, value: int) -> list[Vote]: + return [vote for vote in self.votes if vote.value == value] + @dataclass class Poll: id: str @@ -95,6 +98,11 @@ class Poll: manage_code: str is_whole_day: bool + def pub_date_formatted_notz(self): + date = self.pub_date.replace(tzinfo = None).strftime("%d.%m.%Y") + time = self.pub_date.replace(tzinfo = None).strftime("%H:%M") + return f"Created on {date} at {time}" + def share_url(self): return f"{BASE_URL}/poll/{self.id}" diff --git a/static/styles.css b/static/styles.css index 0e538e8..0ddd9f4 100644 --- a/static/styles.css +++ b/static/styles.css @@ -1,5 +1,5 @@ html { - font-family: "Helvetica Neue", "Arial", sans-serif; + font-family: "Verdana", "Arial", sans-serif !important; font-size: 16px; } @@ -9,8 +9,22 @@ body { margin: 0 auto; } +h1 { + margin-bottom: 40px; +} + +h1 a { + color: black; + text-decoration: none; +} + +h1:hover a { + border-bottom: 2px dotted #fa8e35; + text-decoration: none; +} + textarea { - font-family: "Helvetica Neue", "Arial", sans-serif; + font-family: "Verdana", "Arial", sans-serif; font-size: 16px; } diff --git a/templates/manage.html.j2 b/templates/manage.html.j2 index 4a5da8d..db7da0b 100644 --- a/templates/manage.html.j2 +++ b/templates/manage.html.j2 @@ -3,6 +3,7 @@ {% block content %}

Managing poll {{ poll.title }} by {{ poll.author_name }}

+

{{ poll.pub_date_formatted_notz() }}.

Share this URL with your peers:
diff --git a/templates/poll_vote_list.html.j2 b/templates/poll_vote_list.html.j2 index 845356b..a9b2a48 100644 --- a/templates/poll_vote_list.html.j2 +++ b/templates/poll_vote_list.html.j2 @@ -10,8 +10,10 @@ {{ choice.votes | length }} votes

- {% if choice.votes | length != 0 %} - Voted by: {% for vote in choice.votes %}{{ vote.voter_name }}{% if not loop.last %}, {% endif %}{% endfor %} + {% if choice.votes_with_value(1) | length != 0 %} + Voted by: {% for vote in choice.votes_with_value(1) %} + {{ vote.voter_name }}{% if not loop.last %}, {% endif %} + {% endfor %} {% endif %}
-- cgit v1.3