Skip to content

Commit

Permalink
Fix minor bugs with email and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
bubner committed Jan 24, 2024
1 parent eacd2bd commit a0a818b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/img.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def generate_qrcode(event, size, qr_type) -> BytesIO:
@return: QR code image as a BytesIO object
"""
img = qrcode.make(
f"https://rbreg.vercel.app/events/{qr_type}/{event.get('uid')}" + f"?code={event.get('checkin_code')}" if qr_type == "ci" else "",
f"https://rbreg.vercel.app/events/{qr_type}/{event.get('uid')}" + (f"?code={event.get('checkin_code')}" if qr_type == "ci" else ""),
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L if size == "large" else qrcode.constants.ERROR_CORRECT_H,
box_size=20 if size == "large" else 16,
Expand Down Expand Up @@ -83,10 +83,11 @@ def generate_qrcode(event, size, qr_type) -> BytesIO:
font=smallfont if len(text) > 90 else font)

# Add email
text = "For inquiries contact: " + event.get("email")
text_width, text_height = draw.textlength(text, boldfont), boldfont.size
draw.text(((template_width - text_width) // 2, template_height - text_height - 480), text, (0, 0, 0),
font=boldfont)
if event.get("email") != "N/A":
text = "For inquiries contact: " + event.get("email")
text_width, text_height = draw.textlength(text, boldfont), boldfont.size
draw.text(((template_width - text_width) // 2, template_height - text_height - 480), text, (0, 0, 0),
font=boldfont)
else:
# Add event check-in code
text = str(event.get("checkin_code"))
Expand Down

0 comments on commit a0a818b

Please sign in to comment.