Browse Source

add create new form

master
Thomas Lindner 3 months ago
parent
commit
f212dbe32d
  1. 23
      datentrog.py
  2. 1
      datentrog.tpl
  3. 20
      static/new.html

23
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/<file:path>")
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/<event>")
@bottle.view("datentrog.tpl")
def event_get(event):
return dict(event=event)
@application.post("/event/<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, "")

1
datentrog.tpl

@ -11,7 +11,6 @@
% if get("success", False):
<p>Erfolgreich registriert.</p>
<form method="get">
<input type="hidden" name="event" value="{{ get("event", "Heizhaus") }}">
<button type="submit" class="btn btn-primary">Weitere Person registrieren</button>
</form>
% else:

20
static/new.html

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<title>Corona-Kontaktformular - Neu erstellen</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h1>Corona-Kontaktformular</h1>
<form method="post">
<div class="form-group">
<label for="event">Veranstaltung:</label>
<input id="event" class="form-control" name="event" value="Kunstrasen">
</div>
<button type="submit" class="btn btn-success">Formular erstellen</button>
</form>
</div>
</body>
</html>
Loading…
Cancel
Save