Initial commit: InviteMe event registration app

This commit is contained in:
InviteMe Developer
2026-08-28 12:28:52 +03:00
commit b4e10b8448
23 changed files with 1718 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
import qrcode
from pathlib import Path
from flask import current_app, url_for
def generate_qr_for_guest(guest, base_url=None):
"""Генерирует QR-код для гостя и сохраняет его в uploads/qrcodes/."""
token = guest.token
qr_folder = Path(current_app.config["QR_FOLDER"])
qr_folder.mkdir(parents=True, exist_ok=True)
qr_filename = f"{token}.png"
qr_path = qr_folder / qr_filename
# URL, который будет закодирован в QR
if base_url is None:
try:
check_in_url = url_for("main.check_in", token=token, _external=True)
except Exception:
check_in_url = f"http://localhost:5000/check-in?token={token}"
else:
check_in_url = f"{base_url.rstrip('/')}/check-in?token={token}"
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_H,
box_size=10,
border=4,
)
qr.add_data(check_in_url)
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
img.save(str(qr_path))
guest.qr_filename = qr_filename
return qr_path, check_in_url