improve form creation
This commit is contained in:
parent
f212dbe32d
commit
e8d1d7e31e
29
datentrog.py
29
datentrog.py
|
@ -19,30 +19,35 @@ cursor.execute("""
|
||||||
|
|
||||||
|
|
||||||
@application.get("/")
|
@application.get("/")
|
||||||
def root_get():
|
@bottle.view("template/new.tpl")
|
||||||
return bottle.static_file("new.html", root="static")
|
def new_get():
|
||||||
|
pass
|
||||||
|
|
||||||
@application.get("/static/<file:path>")
|
|
||||||
def datentrog_get(file):
|
|
||||||
return bottle.static_file(file, root="static")
|
|
||||||
|
|
||||||
|
|
||||||
@application.post("/")
|
@application.post("/")
|
||||||
def datentrog_post():
|
@bottle.view("template/new.tpl")
|
||||||
bottle.redirect("event/" + bottle.request.forms.get("event", ""))
|
def new_post():
|
||||||
|
event = bottle.request.forms.get("event", "")
|
||||||
|
if event:
|
||||||
|
bottle.redirect("event/" + event)
|
||||||
|
return dict(event=event, feedback=True)
|
||||||
|
|
||||||
|
|
||||||
|
@application.get("/static/<file:path>")
|
||||||
|
def static_get(file):
|
||||||
|
return bottle.static_file(file, root="static")
|
||||||
|
|
||||||
|
|
||||||
@application.get("/event/<event>")
|
@application.get("/event/<event>")
|
||||||
@bottle.view("datentrog.tpl")
|
@bottle.view("template/event.tpl")
|
||||||
def event_get(event):
|
def event_get(event):
|
||||||
return dict(event=event)
|
return dict(event=event)
|
||||||
|
|
||||||
|
|
||||||
@application.post("/event/<event>")
|
@application.post("/event/<event>")
|
||||||
@bottle.view("datentrog.tpl")
|
@bottle.view("template/event.tpl")
|
||||||
def event_post(event):
|
def event_post(event):
|
||||||
data = {"feedback": True, "success": True}
|
data = dict(feedback=True, success=True)
|
||||||
for field in ("event", "name", "address", "contact"):
|
for field in ("event", "name", "address", "contact"):
|
||||||
data[field] = bottle.request.forms.get(field, "")
|
data[field] = bottle.request.forms.get(field, "")
|
||||||
data["success"] = data["success"] and data[field]
|
data["success"] = data["success"] and data[field]
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Corona-Kontaktformular - {{ get("event", "Heizhaus") }}</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>
|
|
||||||
% if get("success", False):
|
|
||||||
<p>Erfolgreich registriert.</p>
|
|
||||||
<form method="get">
|
|
||||||
<button type="submit" class="btn btn-primary">Weitere Person registrieren</button>
|
|
||||||
</form>
|
|
||||||
% else:
|
|
||||||
<p>Die Daten werden nach 1 Monat gelöscht und ausschließlich zur Corona-Kontaktverfolgung verwendet.</p>
|
|
||||||
<form method="post" autocomplete="on">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="event">Veranstaltung:</label>
|
|
||||||
<input id="event" class="form-control" name="event" value="{{ get("event", "Heizhaus") }}" readonly>
|
|
||||||
</div>
|
|
||||||
<div class="form-group {{ ("has-success" if get("name", False) else "has-error") + " has-feedback" if get("feedback", False) else "" }}">
|
|
||||||
<label for="name">Name, Vorname:</label>
|
|
||||||
<input id="name" class="form-control" placeholder="Söder, Markus" name="name" value="{{ get("name", "") }}">
|
|
||||||
% if get("feedback", False):
|
|
||||||
<span class="glyphicon {{ "glyphicon-ok" if get("name", False) else "glyphicon-remove" }} form-control-feedback"></span>
|
|
||||||
% end
|
|
||||||
</div>
|
|
||||||
<div class="form-group {{ ("has-success" if get("address", False) else "has-error") + " has-feedback" if get("feedback", False) else "" }}">
|
|
||||||
<label for="address">Adresse:</label>
|
|
||||||
<input id="address" class="form-control" placeholder="Jakobstraße 46, 90402 Nürnberg" name="address" value="{{ get("address", "") }}">
|
|
||||||
% if get("feedback", False):
|
|
||||||
<span class="glyphicon {{ "glyphicon-ok" if get("address", False) else "glyphicon-remove" }} form-control-feedback"></span>
|
|
||||||
% end
|
|
||||||
</div>
|
|
||||||
<div class="form-group {{ ("has-success" if get("contact", False) else "has-error") + " has-feedback" if get("feedback", False) else "" }}">
|
|
||||||
<label for="contact">Email/Telefon:</label>
|
|
||||||
<input id="contact" class="form-control" placeholder="markus.soeder@soeder.de" name="contact" value="{{ get("contact", "") }}">
|
|
||||||
% if get("feedback", False):
|
|
||||||
<span class="glyphicon {{ "glyphicon-ok" if get("contact", False) else "glyphicon-remove" }} form-control-feedback"></span>
|
|
||||||
% end
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-success">Registrieren</button>
|
|
||||||
</form>
|
|
||||||
% end
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,20 +0,0 @@
|
||||||
<!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>
|
|
37
template/event.tpl
Normal file
37
template/event.tpl
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
% rebase('template/toplevel.tpl', title=event)
|
||||||
|
% if get("success", False):
|
||||||
|
<p>Erfolgreich registriert.</p>
|
||||||
|
<form method="get">
|
||||||
|
<button type="submit" class="btn btn-primary">Weitere Person registrieren</button>
|
||||||
|
</form>
|
||||||
|
% else:
|
||||||
|
<p>Die Daten werden nach 1 Monat gelöscht und ausschließlich zur Corona-Kontaktverfolgung verwendet.</p>
|
||||||
|
<form method="post" autocomplete="on">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="event">Veranstaltung:</label>
|
||||||
|
<input id="event" class="form-control" name="event" value="{{ get("event", "Heizhaus") }}" readonly>
|
||||||
|
</div>
|
||||||
|
<div class="form-group {{ ("has-success" if get("name", False) else "has-error") + " has-feedback" if get("feedback", False) else "" }}">
|
||||||
|
<label for="name">Name, Vorname:</label>
|
||||||
|
<input id="name" class="form-control" placeholder="Söder, Markus" name="name" value="{{ get("name", "") }}">
|
||||||
|
% if get("feedback", False):
|
||||||
|
<span class="glyphicon {{ "glyphicon-ok" if get("name", False) else "glyphicon-remove" }} form-control-feedback"></span>
|
||||||
|
% end
|
||||||
|
</div>
|
||||||
|
<div class="form-group {{ ("has-success" if get("address", False) else "has-error") + " has-feedback" if get("feedback", False) else "" }}">
|
||||||
|
<label for="address">Adresse:</label>
|
||||||
|
<input id="address" class="form-control" placeholder="Jakobstraße 46, 90402 Nürnberg" name="address" value="{{ get("address", "") }}">
|
||||||
|
% if get("feedback", False):
|
||||||
|
<span class="glyphicon {{ "glyphicon-ok" if get("address", False) else "glyphicon-remove" }} form-control-feedback"></span>
|
||||||
|
% end
|
||||||
|
</div>
|
||||||
|
<div class="form-group {{ ("has-success" if get("contact", False) else "has-error") + " has-feedback" if get("feedback", False) else "" }}">
|
||||||
|
<label for="contact">Email/Telefon:</label>
|
||||||
|
<input id="contact" class="form-control" placeholder="markus.soeder@soeder.de" name="contact" value="{{ get("contact", "") }}">
|
||||||
|
% if get("feedback", False):
|
||||||
|
<span class="glyphicon {{ "glyphicon-ok" if get("contact", False) else "glyphicon-remove" }} form-control-feedback"></span>
|
||||||
|
% end
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-success">Registrieren</button>
|
||||||
|
</form>
|
||||||
|
% end
|
11
template/new.tpl
Normal file
11
template/new.tpl
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
% rebase('template/toplevel.tpl', title='Neu erstellen')
|
||||||
|
<form method="post">
|
||||||
|
<div class="form-group {{ ("has-success" if get("event", False) else "has-error") + " has-feedback" if get("feedback", False) else "" }}">
|
||||||
|
<label for="event">Veranstaltung:</label>
|
||||||
|
<input id="event" class="form-control" placeholder="Kunstrasen" name="event" value="{{ get("event", "") }}">
|
||||||
|
% if get("feedback", False):
|
||||||
|
<span class="glyphicon {{ "glyphicon-ok" if get("event", False) else "glyphicon-remove" }} form-control-feedback"></span>
|
||||||
|
% end
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-success">Formular erstellen</button>
|
||||||
|
</form>
|
14
template/toplevel.tpl
Normal file
14
template/toplevel.tpl
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Corona-Kontaktformular - {{ get("title", "Heizhaus") }}</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>
|
||||||
|
{{!base}}
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in a new issue