aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2022-08-07 11:05:03 +0200
committerAndrea Lepori <alepori@student.ethz.ch>2022-08-07 11:05:03 +0200
commitc4ccf8af5f82c359bbe79538d8e745e21f17f06a (patch)
treeb0bd6b80d1d913d6727bd57476fb1eae3e20dbae /client
parentunified approve doc page (diff)
downloadscout-subs-c4ccf8af5f82c359bbe79538d8e745e21f17f06a.tar.gz
scout-subs-c4ccf8af5f82c359bbe79538d8e745e21f17f06a.zip
add qr code to pdf approve, direct approval page
Diffstat (limited to '')
-rw-r--r--client/templates/client/approve_doc_pdf.html20
-rw-r--r--client/views.py3
2 files changed, 21 insertions, 2 deletions
diff --git a/client/templates/client/approve_doc_pdf.html b/client/templates/client/approve_doc_pdf.html
index 244bc20..0cf4944 100644
--- a/client/templates/client/approve_doc_pdf.html
+++ b/client/templates/client/approve_doc_pdf.html
@@ -8,7 +8,12 @@
</head>
<body style="background: white;">
<main style="margin-left: 10px;margin-right: 10px;margin-top: 10px; background: white;">
- <br><br><br><br>
+ <div style="position: absolute; top: 10px; left: 10px;">
+ <div id="qrcode"></div>
+ </div>
+ <div class="row center">
+ <svg id="barcode"></svg>
+ </div>
<br><br>
<div class="row">
<p class="center">{{doc.user.first_name}} {{doc.user.last_name}} ({{doc.user.username}})</p>
@@ -55,4 +60,17 @@
</main>
</body>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
+<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jsbarcode@3.11.5/dist/barcodes/JsBarcode.code128.min.js"></script>
+<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
+<script type="text/javascript">
+ JsBarcode("#barcode", {{doc.code}}, {width: 3, height: 40, displayValue: false});
+ var qrcode = new QRCode(document.getElementById("qrcode"), {
+ text: "{{ uri }}",
+ width: 128,
+ height: 128,
+ colorDark : "#000000",
+ colorLight : "#ffffff",
+ correctLevel : QRCode.CorrectLevel.H
+ });
+</script>
</html> \ No newline at end of file
diff --git a/client/views.py b/client/views.py
index 86142ef..3ddc417 100644
--- a/client/views.py
+++ b/client/views.py
@@ -1,5 +1,6 @@
from django.db.models.expressions import OuterRef, Subquery
from django.template.loader import get_template
+from django.urls import reverse
from client.models import GroupSettings, UserCode, Keys, DocumentType, Document, PersonalData, KeyVal, MedicalData
from django.db.models import Q
from django.http import HttpResponse, HttpResponseRedirect, FileResponse
@@ -57,7 +58,7 @@ def index(request):
if request.POST["action"][0] == 'f':
# generate approve pdf
template = get_template('client/approve_doc_pdf.html')
- context = {'doc': document}
+ context = {'doc': document, 'uri': request.build_absolute_uri(reverse('approve_direct')) + "?code=" + str(document.code)}
html = template.render(context)
pdf = pdfkit.from_string(html, False)
result = BytesIO(pdf)