Jul 7 - Implement QR codes for facility

This commit is contained in:
2026-07-07 21:05:07 -04:00
parent 8b5a4758e5
commit faab9fd008
12 changed files with 684 additions and 7 deletions
+24
View File
@@ -0,0 +1,24 @@
"""
app/utils/qr.py
---------------
Generic QR-code SVG helper (phase38).
Mirrors qr_svg() in app/utils/mfa.py (which is TOTP-specific and mirrored in
control/mfa.py — do not touch those; this is the general-purpose variant for
facility QR codes and any future QR needs).
"""
import io
import qrcode
import qrcode.image.svg
def qr_svg(data: str) -> str:
"""Return an inline SVG string encoding `data` (no Pillow needed).
The SVG carries its own width/height attrs; size it via CSS on the
containing element (svg { width:…; height:…; }) when embedding.
"""
buf = io.BytesIO()
qrcode.make(data, image_factory=qrcode.image.svg.SvgPathImage).save(buf)
return buf.getvalue().decode('utf-8')