From f212dbe32d2918092c03178eaf058a35d0da07e1 Mon Sep 17 00:00:00 2001 From: Thomas Lindner Date: Tue, 9 Nov 2021 04:38:04 +0100 Subject: [PATCH] add create new form --- datentrog.py | 23 +++++++++++++++++++---- datentrog.tpl | 1 - static/new.html | 20 ++++++++++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 static/new.html diff --git a/datentrog.py b/datentrog.py index 62b4f1a..6a87d03 100755 --- a/datentrog.py +++ b/datentrog.py @@ -19,14 +19,29 @@ cursor.execute(""" @application.get("/") -@bottle.view("datentrog.tpl") -def datentrog_get(): - return dict(event=bottle.request.query.get("event", "Heizhaus")) +def root_get(): + return bottle.static_file("new.html", root="static") + + +@application.get("/static/") +def datentrog_get(file): + return bottle.static_file(file, root="static") @application.post("/") -@bottle.view("datentrog.tpl") def datentrog_post(): + bottle.redirect("event/" + bottle.request.forms.get("event", "")) + + +@application.get("/event/") +@bottle.view("datentrog.tpl") +def event_get(event): + return dict(event=event) + + +@application.post("/event/") +@bottle.view("datentrog.tpl") +def event_post(event): data = {"feedback": True, "success": True} for field in ("event", "name", "address", "contact"): data[field] = bottle.request.forms.get(field, "") diff --git a/datentrog.tpl b/datentrog.tpl index 32f4844..f35bb9d 100644 --- a/datentrog.tpl +++ b/datentrog.tpl @@ -11,7 +11,6 @@ % if get("success", False):

Erfolgreich registriert.

-
% else: diff --git a/static/new.html b/static/new.html new file mode 100644 index 0000000..52fd226 --- /dev/null +++ b/static/new.html @@ -0,0 +1,20 @@ + + + + Corona-Kontaktformular - Neu erstellen + + + + +
+

Corona-Kontaktformular

+
+
+ + +
+ +
+
+ +