summaryrefslogtreecommitdiff
path: root/routes/base.py
diff options
context:
space:
mode:
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()
-# )