diff options
Diffstat (limited to 'jimbrella/web.py')
-rw-r--r-- | jimbrella/web.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/jimbrella/web.py b/jimbrella/web.py index 4237055..434de57 100644 --- a/jimbrella/web.py +++ b/jimbrella/web.py @@ -1,4 +1,4 @@ -from flask import Flask, request, render_template +from flask import Flask, request, render_template, redirect, url_for from user_agents import parse as user_agent from .database import Database from .config import * @@ -25,12 +25,33 @@ def admin_index(): @app.route("/admin/umbrellas") def admin_umbrellas(): umbrellas = db.read() + edit = request.args.get("edit") return render_template( "admin/umbrellas.html", umbrellas=umbrellas, + edit=int(edit) if edit else None, mobile=user_agent(request.user_agent.string).is_mobile, ) +@app.route("/admin/umbrellas/edit", methods=["POST"]) +def admin_umbrellas_edit(): + data = {} + for key in [ + "serial", + "alias", + "status", + "tenant_name", + "tenant_id", + "tenant_phone", + "tenant_email", + "lent_at", + ]: + data[key] = request.form.get(key) + + db.update(data) + return redirect("/admin/umbrellas") + + if __name__ == "__main__": app.run() |