aboutsummaryrefslogtreecommitdiffstats
path: root/db.py
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2024-02-29 22:04:55 +0200
committerJan Tuomi <jan@jantuomi.fi>2024-12-21 19:43:13 +0200
commit3620ac2671651eb096e49845e2ef500918e90d2a (patch)
tree20d36d20b39fe02f501513a2241b5636f672d8ac /db.py
parent5c64529e77f150f8b83930f17e792b2cb8e38a87 (diff)
Fix list view voters, change font
Diffstat (limited to 'db.py')
-rw-r--r--db.py8
1 files changed, 8 insertions, 0 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}"