Compare commits

...

2 Commits

Author SHA1 Message Date
Peter J. Holzer b7ee8faf4d Log users who vote 2024-10-19 19:30:31 +02:00
Peter J. Holzer a9a778b4c3 Add links to votes 2024-10-19 19:17:21 +02:00
2 changed files with 32 additions and 10 deletions

20
app.py
View File

@ -31,7 +31,22 @@ def home():
log.debug("session = %s", session)
if "user" not in session:
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"])
def register():
@ -142,6 +157,7 @@ def vote(key):
@app.post("/vote/date")
def vote_date():
log.debug("user = %s", session["user"])
log.debug("form = %s", request.form)
meet_id, preferences = get_preferences("date")
date_ids = list(preferences.keys())
@ -211,6 +227,7 @@ def result_date(meet_id):
@app.post("/vote/time")
def vote_time():
log.debug("user = %s", session["user"])
log.debug("form = %s", request.form)
meet_id, preferences = get_preferences("time")
time_ids = list(preferences.keys())
@ -278,6 +295,7 @@ def result_time(meet_id):
@app.post("/vote/place")
def vote_place():
log.debug("user = %s", session["user"])
log.debug("form = %s", request.form)
meet_id, preferences = get_preferences("place")
place_ids = list(preferences.keys())

View File

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