feat: add privacy policy
feat: add index
This commit is contained in:
1 parent
43185dee64
commit
819b9a13dd
7 files changed
+247
-5
No files matched your search
@@ -9,6 +9,7 @@ import os
|
||||
import time
|
||||
from functools import wraps
|
||||
from db import init_db, get_db, close_db, create_participant, now
|
||||
from datetime import datetime, timezone
|
||||
|
||||
bp = Blueprint("main", __name__)
|
||||
|
||||
@@ -23,10 +24,22 @@ def load_songs_list():
|
||||
with open(BASE_DIR / "data" / "songs.json", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
|
||||
@bp.route("/datenschutz")
|
||||
def datenschutz():
|
||||
return render_template("datenschutz.html")
|
||||
|
||||
@bp.route("/agree-dse", methods=["POST"])
|
||||
def agree_dse():
|
||||
session["dse_agreed"] = True
|
||||
session["dse_agreed_at"] = datetime.now(timezone.utc).isoformat()
|
||||
return redirect(url_for("main.index"))
|
||||
|
||||
@bp.route("/login")
|
||||
def login():
|
||||
if "name" in session:
|
||||
return redirect(url_for("main.index"))
|
||||
elif "dse_agreed" not in session:
|
||||
return redirect(url_for("main.datenschutz"))
|
||||
return render_template("login.html")
|
||||
|
||||
|
||||
@@ -39,7 +52,7 @@ def index():
|
||||
session.clear() # neuer Teilnehmer = frischer Stand
|
||||
session["name"] = name
|
||||
session["pid"] = create_participant(name)
|
||||
return redirect(url_for("main.test"))
|
||||
#return redirect(url_for("main.test"))
|
||||
if "pid" not in session:
|
||||
return redirect(url_for("main.login"))
|
||||
return render_template("index.html")
|
||||
@@ -50,12 +63,16 @@ def index():
|
||||
def test():
|
||||
if "name" not in session:
|
||||
return redirect(url_for("main.index"))
|
||||
elif "dse_agreed" not in session:
|
||||
return redirect(url_for("main.datenschutz"))
|
||||
return render_template("test.html", name=session["name"])
|
||||
|
||||
@bp.route("/api/getRandomSong")
|
||||
def api_getRandomSong():
|
||||
if "name" not in session:
|
||||
return jsonify({"error": "no session detected"}), 401
|
||||
elif "dse_agreed" not in session:
|
||||
return jsonify({"error": "no agreement on privacy policy detected"}), 401
|
||||
|
||||
done = session.get("done", [])
|
||||
#print(done)
|
||||
@@ -90,6 +107,8 @@ def api_getRandomSong():
|
||||
def api_rate():
|
||||
if "pid" not in session or "current" not in session:
|
||||
return jsonify({"error": "no session detected"}), 401
|
||||
elif "dse_agreed" not in session:
|
||||
return redirect(url_for("main.datenschutz"))
|
||||
|
||||
data = request.get_json(silent=True) or {}
|
||||
choice = data.get("choice")
|
||||
@@ -113,8 +132,12 @@ def api_rate():
|
||||
done.append(cur["id"])
|
||||
session["done"] = done
|
||||
session.pop("current", None)
|
||||
|
||||
truth = cur["truth"]
|
||||
if not current_app.debug:
|
||||
truth = False
|
||||
|
||||
return jsonify({"saved": True})
|
||||
return jsonify({"saved": True, "solution": {"truth": truth, "choice": choice}})
|
||||
|
||||
|
||||
def admin_required(view):
|
||||
|
||||
Reference in new issue
Block a user