From b6db3f0ea9f67a4f2687a5b78d3a4459c1a77620 Mon Sep 17 00:00:00 2001
From: "Peter J. Holzer" <hjp@hjp.at>
Date: Wed, 9 Nov 2022 00:04:07 +0100
Subject: [PATCH] List people who already voted

---
 app.py              | 21 ++++++++++++++++++++-
 static/style.css    |  9 ++++++++-
 templates/vote.html |  8 +++++++-
 3 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/app.py b/app.py
index b06dfd8..de0b93c 100644
--- a/app.py
+++ b/app.py
@@ -86,6 +86,25 @@ def vote(key):
     if not meet:
         abort(404)
 
+    csr.execute(
+        """
+        select email from bod where id in (
+            select date_vote.bod
+            from date join date_vote on date.id = date_vote.date
+            where meet = %(meet_id)s
+            union
+            select time_vote.bod
+            from time join time_vote on time.id = time_vote.time
+            where meet = %(meet_id)s
+            union
+            select place_vote.bod
+            from place join place_vote on place.id = place_vote.place
+            where meet = %(meet_id)s
+        ) order by 1
+        """,
+        { "meet_id": meet.id,})
+    voters = csr.fetchall()
+
     csr.execute(
             """
             select d.id, d.date, d.display, position
@@ -114,7 +133,7 @@ def vote(key):
     places = csr.fetchall()
 
     return render_template("vote.html",
-                meet=meet, dates=dates, times=times, places=places)
+                meet=meet, voters=voters,dates=dates, times=times, places=places)
 
 @app.post("/vote/date")
 def vote_date():
diff --git a/static/style.css b/static/style.css
index 93cf0b7..eb95f88 100644
--- a/static/style.css
+++ b/static/style.css
@@ -19,16 +19,23 @@ body {
 }
 
 body {
+    padding: 1rem;
     display: grid;
     grid-template-columns: 1fr 1fr;
     grid-column-gap: 2em;
+    line-height: 1.5em;
 }
 
-#hello {
+p {
+  margin-top: 0;
+}
+
+#hello, #voters {
     grid-column: 1  / 3;
 }
 h1, h2 {
     grid-column: 1  / 3;
+    line-height: 1.1em;
 }
 
 .result-item {
diff --git a/templates/vote.html b/templates/vote.html
index 31c348f..e7e6caf 100644
--- a/templates/vote.html
+++ b/templates/vote.html
@@ -8,7 +8,13 @@
     <link rel="stylesheet" href="/static/style.css">
   </head>
   <body>
-    <p  id="hello">Hallo, {{ session.user.email }}!</p>
+    <p id="hello">Hallo, {{ session.user.email }}!</p>
+    <p id="voters">
+      Bisher haben abgestimmt:
+      {% for voter in voters %}
+        {{ voter.email }}{% if not loop.last %},{% endif %}
+      {% endfor %}
+    </p>
     <h1>
       {{ meet.title }}
     </h1>