summaryrefslogtreecommitdiff
path: root/routes/base.py
diff options
context:
space:
mode:
authorLilian Teronen <lteronen@local>2023-11-27 01:37:03 +0200
committerLilian Teronen <lteronen@local>2023-11-27 01:37:03 +0200
commit03b031ea793e91ce2f87cf28c73cefc8ce69a7b5 (patch)
tree882919559651e1b18904404ccc7c5106d167f1fd /routes/base.py
parentd2de3ae10b6f5314bd4b8243218212d2004f35b0 (diff)
More rework on routes. Best and worst matches. More visuals.
Diffstat (limited to 'routes/base.py')
-rw-r--r--routes/base.py39
1 files changed, 18 insertions, 21 deletions
diff --git a/routes/base.py b/routes/base.py
index 695388b..22245c5 100644
--- a/routes/base.py
+++ b/routes/base.py
@@ -9,43 +9,40 @@ def index():
@app.route("/pages/info.html")
def info():
- return render_template("info.html",
+ if "id" in session:
+ return render_template(
+ "info.html",
+ caller="info",
+ alert=get_alert(),
+ nick=get_nick()
+ )
+ return render_template(
+ "info.html",
+ caller="info",
alert=get_alert()
)
-@app.route("/pages/nick.html")
-def nick():
- return render_template("nick.html",
- alert=get_alert()
- )
-
@app.route("/set/nick",methods=["POST"])
def new_nick():
+ next = "/#"+request.form["caller"] if "caller" in request.form else "/"
if "id" in session.keys():
session["alert"]="Sinulla on jo nimimerkki. Käytä sitä."
- return redirect("/")
+ return redirect(next)
if "nick" not in request.form or request.form["nick"]=="":
session["alert"]="Nimimerkkiä ei voi asettaa ilman nimimerkkiä."
- return redirect("/#nick")
+ return redirect(next)
else:
nick = request.form["nick"]
if len(nick) < 4:
session["alert"]="Nimimerkki on liian lyhyt"
- return redirect("/#nick")
+ return redirect(next)
if not nick.isalnum():
session["alert"]="Nimimerkissä saa olla vain kirjaimia ja numeroita."
- return redirect("/#nick")
+ return redirect(next)
if D.user_exists(nick):
session["alert"]="Nimimerkki jonka olet ottamassa on jo varattu."
- return redirect("/#nick")
- session["id"] = D.user_new(nick)
- return redirect("/")
-
-
+ return redirect(next)
+ session["id"] = int(D.user_new(nick))
+ return redirect(next)
-#@app.route("/pages/moderate.html")
-#def moderate():
-# return render_template("moderate.html",
-# alert=get_alert()
-# )