2 Commits

Author SHA1 Message Date
Thomas Lindner 49bbe12917 provide qr codes for printing 3 months ago
Thomas Lindner a02d190438 rename Veranstaltung -> Veranstaltungsort 3 months ago
  1. 29
      datentrog.py
  2. BIN
      heizhaus_logo.png
  3. BIN
      heizhaus_logo_circle.png
  4. BIN
      heizhaus_logo_square.png
  5. 1
      requirements.txt
  6. 4
      template/event.tpl
  7. 6
      template/new.tpl
  8. 7
      template/qr.tpl

29
datentrog.py

@ -1,5 +1,8 @@
#!/usr/bin/env python3
import bottle
import io
import qrcode
import qrcode.image.styledpil as qrstyled
import sqlite3
@ -18,6 +21,13 @@ cursor.execute("""
""")
def url(route):
return '%s://%s/%s' % (
bottle.request.urlparts.scheme,
bottle.request.urlparts.netloc,
route)
@application.get("/")
@bottle.view("template/new.tpl")
def new_get():
@ -29,7 +39,7 @@ def new_get():
def new_post():
event = bottle.request.forms.get("event", "")
if event:
bottle.redirect("event/" + event)
bottle.redirect(url("qr/" + event))
return dict(event=event, feedback=True)
@ -38,6 +48,23 @@ def static_get(file):
return bottle.static_file(file, root="static")
@application.get("/qr/<event>")
@bottle.view("template/qr.tpl")
def qr_get(event):
return dict(event=event, url=url("event/" + event))
@application.get("/qr/img/<event>.png")
def qr_img_get(event):
qr = qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_H, box_size=20)
qr.add_data(url("event/" + event))
image = qr.make_image(image_factory=qrstyled.StyledPilImage, embeded_image_path="heizhaus_logo_square.png")
buffer = io.BytesIO()
image.save(buffer, format="PNG")
bottle.response.content_type = "image/png"
return buffer.getvalue()
@application.get("/event/<event>")
@bottle.view("template/event.tpl")
def event_get(event):

BIN
heizhaus_logo.png

After

Width: 150  |  Height: 156  |  Size: 4.9 KiB

BIN
heizhaus_logo_circle.png

After

Width: 210  |  Height: 210  |  Size: 18 KiB

BIN
heizhaus_logo_square.png

After

Width: 210  |  Height: 210  |  Size: 12 KiB

1
requirements.txt

@ -1 +1,2 @@
bottle
qrcode[pil]

4
template/event.tpl

@ -1,4 +1,4 @@
% rebase('template/toplevel.tpl', title=event)
% rebase("template/toplevel.tpl", title=event)
% if get("success", False):
<div class="alert alert-success">Erfolgreich registriert.</div>
<form method="get">
@ -8,7 +8,7 @@
<div class="alert alert-warning">Da sich eine <a href="https://www.br.de/nachrichten/bayern/gesundheitsaemter-stellen-breite-corona-kontaktnachverfolgung-ein">Benachrichtigung durch das Gesundheitsamt verzögern/ausfallen</a> kann, wird empfohlen die <a href="https://www.coronawarn.app">Corona-Warn-App</a> zu verwenden.</div>
<form method="post" autocomplete="on">
<div class="form-group">
<label for="event">Veranstaltung:</label>
<label for="event">Veranstaltungsort:</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 "" }}">

6
template/new.tpl

@ -1,8 +1,8 @@
% rebase('template/toplevel.tpl', title='Neu erstellen')
% 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", "") }}">
<label for="event">Veranstaltungsort:</label>
<input id="event" class="form-control" placeholder="Heizhaus" 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

7
template/qr.tpl

@ -0,0 +1,7 @@
% rebase("template/toplevel.tpl", title=event)
<div class="hidden-print">
<a class="btn btn-default" href="{{ url }}">Zum Formular</a>
<button class="btn btn-primary" onclick="window.print()">Drucken</button>
</div>
<img class="img-responsive" src="img/{{ event }}.png" alt="QR-Code">
<p class="lead">{{ url }}</p>
Loading…
Cancel
Save