Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump pillow from 10.0.1 to 10.2.0 in /src #29

Merged
merged 4 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def login():
user = auth.sign_in_with_email_and_password(email, password)
if not user:
return redirect("/login")
login_user(User(user.get("refreshToken")), remember=request.form.get("remember-me", False))
login_user(User(user.get("refreshToken")), remember=bool(request.form.get("remember-me", False)))
return redirect("/")
except Exception:
return render_template("auth/login.html.jinja", error="Invalid email or password.")
Expand Down Expand Up @@ -92,7 +92,7 @@ def register():
user = auth.sign_in_with_email_and_password(email, password)
if not user:
return redirect("/login")
login_user(User(user.get("refreshToken")), remember=request.form.get("remember-me", False))
login_user(User(user.get("refreshToken")), remember=bool(request.form.get("remember-me", False)))
return res
except HTTPError as e:
# String hack since the HTTP error object refuses to cooperate
Expand Down
33 changes: 15 additions & 18 deletions src/img.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@ def generate_qrcode(event, size, qr_type) -> BytesIO:
Generates a QR code for RoboRegistry registration or check-in
@return: QR code image as a BytesIO object
"""
qr = qrcode.QRCode(
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 ""),
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,
border=0 if size == "large" else 2,
)
qr.add_data(f"https://rbreg.vercel.app/events/{qr_type}/{event.get('uid')}?code={event.get('checkin_code')}")
qr.make(fit=True)

# Generate QR code image
img = qr.make_image(fill_color="black", back_color="white")

# Open the RoboRegistry template depending on size and type
if size == "large" and qr_type == "register":
Expand Down Expand Up @@ -64,37 +60,38 @@ def generate_qrcode(event, size, qr_type) -> BytesIO:

# Add URL
text = f"https://roboregistry.vercel.app/events/{qr_type}/{event.get('uid')}"
text_width, text_height = draw.textsize(text, boldfont)
text_width, text_height = draw.textlength(text, boldfont), boldfont.size
draw.text(((template_width - text_width) // 2, template_height - text_height - 1000), text, (0, 0, 0),
font=boldfont)

# Add event name
text = event.get("name").upper()
text_width, text_height = draw.textsize(text, bigfont)
text_width, text_height = draw.textlength(text, bigfont), bigfont.size
draw.text(((template_width - text_width) // 2, 800 + text_height), text, (0, 0, 0), font=bigfont)

if qr_type == "register":
# Add event details
text = f"{event.get('date')} | {event.get('start_time')} - {event.get('end_time')}"
text_width, text_height = draw.textsize(text, font)
text_width, text_height = draw.textlength(text, font), font.size
draw.text(((template_width - text_width) // 2, template_height - text_height - 700), text, (0, 0, 0),
font=font)

# Add location
text = event.get("location")
text_width, text_height = draw.textsize(text, smallfont if len(text) > 90 else font)
text_width, text_height = draw.textlength(text, smallfont if len(text) > 90 else font), smallfont.size if len(text) > 90 else font.size
draw.text(((template_width - text_width) // 2, template_height - text_height - 600), text, (0, 0, 0),
font=smallfont if len(text) > 90 else font)

# Add email
text = "For inquiries contact: " + event.get("email")
text_width, text_height = draw.textsize(text, boldfont)
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"))
text_width, text_height = draw.textsize(text, bigfont)
text_width, text_height = draw.textlength(text, bigfont), bigfont.size
draw.text(((template_width - text_width) // 2, template_height - text_height - 480), text, (0, 0, 0),
font=bigfont)

Expand Down Expand Up @@ -193,11 +190,11 @@ def _queue(entities) -> BytesIO:

# Draw a table header for the extra walk-ins, with the values Name, Affiliation, and Time
font = ImageFont.truetype("static/assets/Roboto-Black.ttf", 40)
draw.text((100 + 200 + maxlen * 20 + 100 + (500 - font.getsize("Name")[0]) // 2, 400), "Name", (0, 0, 0),
draw.text((100 + 200 + maxlen * 20 + 100 + (500 - font.getbbox("Name")[2]) // 2, 400), "Name", (0, 0, 0),
font=font)
draw.text((100 + 200 + maxlen * 20 + 100 + 500 + (500 - font.getsize("Affiliation")[0]) // 2, 400),
draw.text((100 + 200 + maxlen * 20 + 100 + 500 + (500 - font.getbbox("Affiliation")[2]) // 2, 400),
"Affiliation", (0, 0, 0), font=font)
draw.text((100 + 200 + maxlen * 20 + 100 + 500 + 500 + (500 - font.getsize("Time")[0]) // 2, 400), "Time",
draw.text((100 + 200 + maxlen * 20 + 100 + 500 + 500 + (500 - font.getbbox("Time")[2]) // 2, 400), "Time",
(0, 0, 0), font=font)

# Draw table cells
Expand Down
2 changes: 1 addition & 1 deletion src/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Jinja2==3.1.3
jwcrypto==1.5.1
MarkupSafe==2.1.2
outcome==1.2.0
Pillow==10.0.1
Pillow==10.2.0
pkce==1.0.3
proto-plus==1.22.2
protobuf==4.23.0
Expand Down