Add links to votes

This commit is contained in:
Peter J. Holzer 2024-10-19 19:17:21 +02:00
parent ac2e4f0b62
commit a9a778b4c3
2 changed files with 29 additions and 10 deletions

17
app.py
View File

@ -31,7 +31,22 @@ def home():
log.debug("session = %s", session) log.debug("session = %s", session)
if "user" not in session: if "user" not in session:
return redirect(url_for("register", target="/")) return redirect(url_for("register", target="/"))
return render_template("home.html") csr = get_cursor()
csr.execute(
"""
select * from meet where id in (
select meet from date_vote dv join date d on dv.date = d.id where bod = %(bod_id)s
union
select meet from time_vote tv join time t on tv.time = t.id where bod = %(bod_id)s
union
select meet from place_vote pv join place p on pv.place = p.id where bod = %(bod_id)s
)
order by id desc
""",
{"bod_id": session["user"]["id"]}
)
meets = csr.fetchall()
return render_template("home.html", meets=meets)
@app.route("/register", methods=["GET", "POST"]) @app.route("/register", methods=["GET", "POST"])
def register(): def register():

View File

@ -6,14 +6,18 @@
</head> </head>
<body> <body>
<p>Hallo, {{ session.user.email }}!</p> <p>Hallo, {{ session.user.email }}!</p>
<p>
{{ session }} {% for meet in meets %}
</p> {% if loop.first %}
<p> <ul>
{{ session.user }} {% endif %}
</p> <li><a href="{{url_for("vote", key=meet.key)}}">{{meet.title}}</a></li>
<p> {% if loop.last %}
{{ session.user.1 }} </ul>
</p> {% endif %}
{% else %}
<p>(Du hast noch an keiner Abstimmung teilgenommen)</p>
{% endfor %}
</body> </body>
</html> </html>