Merge branch 'master' of git.hjp.at:hjp/meeat
This commit is contained in:
commit
41d545d191
23
app.py
23
app.py
|
@ -27,7 +27,7 @@ def home():
|
||||||
log.debug("in home")
|
log.debug("in 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'))
|
return redirect(url_for("register", target="/"))
|
||||||
return render_template("home.html")
|
return render_template("home.html")
|
||||||
|
|
||||||
@app.route("/register", methods=["GET", "POST"])
|
@app.route("/register", methods=["GET", "POST"])
|
||||||
|
@ -54,7 +54,12 @@ def register():
|
||||||
csr.execute(
|
csr.execute(
|
||||||
"insert into bod(email, key, keychange) values(%s, %s, now())",
|
"insert into bod(email, key, keychange) values(%s, %s, now())",
|
||||||
(email_address, key,))
|
(email_address, key,))
|
||||||
confirmation_url = url_for("confirm",
|
log.debug("request.scheme = %s", request.scheme)
|
||||||
|
log.debug("request.server = %s", request.server)
|
||||||
|
log.debug("request.root_url = %s", request.root_url)
|
||||||
|
confirmation_url = \
|
||||||
|
request.root_url + \
|
||||||
|
url_for("confirm",
|
||||||
target=request.form["target"],
|
target=request.form["target"],
|
||||||
key=key)
|
key=key)
|
||||||
send_mail(email_address, confirmation_url)
|
send_mail(email_address, confirmation_url)
|
||||||
|
@ -73,6 +78,8 @@ def confirm():
|
||||||
@app.route("/vote/<string:key>")
|
@app.route("/vote/<string:key>")
|
||||||
def vote(key):
|
def vote(key):
|
||||||
log.debug("session = %s", session)
|
log.debug("session = %s", session)
|
||||||
|
if "user" not in session:
|
||||||
|
return redirect(url_for("register", target=request.url))
|
||||||
csr = get_cursor()
|
csr = get_cursor()
|
||||||
csr.execute("select * from meet where key = %s", (key,))
|
csr.execute("select * from meet where key = %s", (key,))
|
||||||
meet = csr.fetchone()
|
meet = csr.fetchone()
|
||||||
|
@ -126,7 +133,9 @@ def vote_date():
|
||||||
abort(400)
|
abort(400)
|
||||||
meet_id = r[0].meet
|
meet_id = r[0].meet
|
||||||
|
|
||||||
csr.execute("delete from date_vote where date = any (%s)", (date_ids,))
|
csr.execute(
|
||||||
|
"delete from date_vote where date = any (%s) and bod = %s",
|
||||||
|
(date_ids, session["user"]["id"]))
|
||||||
for pos, date_id in enumerate(date_ids):
|
for pos, date_id in enumerate(date_ids):
|
||||||
csr.execute(
|
csr.execute(
|
||||||
"insert into date_vote(date, bod, position) values(%s, %s, %s)",
|
"insert into date_vote(date, bod, position) values(%s, %s, %s)",
|
||||||
|
@ -160,7 +169,9 @@ def vote_time():
|
||||||
abort(400)
|
abort(400)
|
||||||
meet_id = r[0].meet
|
meet_id = r[0].meet
|
||||||
|
|
||||||
csr.execute("delete from time_vote where time = any (%s)", (time_ids,))
|
csr.execute(
|
||||||
|
"delete from time_vote where time = any (%s) and bod = %s",
|
||||||
|
(time_ids, session["user"]["id"]))
|
||||||
for pos, time_id in enumerate(time_ids):
|
for pos, time_id in enumerate(time_ids):
|
||||||
csr.execute(
|
csr.execute(
|
||||||
"insert into time_vote(time, bod, position) values(%s, %s, %s)",
|
"insert into time_vote(time, bod, position) values(%s, %s, %s)",
|
||||||
|
@ -194,7 +205,9 @@ def vote_place():
|
||||||
abort(400)
|
abort(400)
|
||||||
meet_id = r[0].meet
|
meet_id = r[0].meet
|
||||||
|
|
||||||
csr.execute("delete from place_vote where place = any (%s)", (place_ids,))
|
csr.execute(
|
||||||
|
"delete from place_vote where place = any (%s) and bod = %s",
|
||||||
|
(place_ids, session["user"]["id"]))
|
||||||
for pos, place_id in enumerate(place_ids):
|
for pos, place_id in enumerate(place_ids):
|
||||||
csr.execute(
|
csr.execute(
|
||||||
"insert into place_vote(place, bod, position) values(%s, %s, %s)",
|
"insert into place_vote(place, bod, position) values(%s, %s, %s)",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
flask
|
flask
|
||||||
procrusql
|
procrusql >= 0.0.10
|
||||||
psycopg
|
psycopg
|
||||||
psycopg2
|
psycopg2
|
||||||
|
gunicorn
|
||||||
|
|
|
@ -12,6 +12,10 @@ body {
|
||||||
border-radius: 0.2em;
|
border-radius: 0.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.blue-background-class {
|
||||||
|
background: #CDF;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
display: grid;
|
display: grid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
htmx.onLoad(function(content) {
|
function activateSortables(element) {
|
||||||
var sortables = document.querySelectorAll(".sortable");
|
var sortables = document.querySelectorAll(".sortable");
|
||||||
for (const sortable of sortables) {
|
for (const sortable of sortables) {
|
||||||
console.debug("making", sortable, "sortable")
|
console.debug("making", sortable, "sortable")
|
||||||
|
@ -62,7 +62,10 @@
|
||||||
ghostClass: 'blue-background-class'
|
ghostClass: 'blue-background-class'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
activateSortables(document)
|
||||||
|
//htmx.onLoad(function(content) { activateSortables(content) }
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue