From c0c7067b6da619cd26183798230962f21607f54d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 21:59:44 +0000 Subject: [PATCH 1/4] Bump pillow from 10.0.1 to 10.2.0 in /src Bumps [pillow](https://github.com/python-pillow/Pillow) from 10.0.1 to 10.2.0. - [Release notes](https://github.com/python-pillow/Pillow/releases) - [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst) - [Commits](https://github.com/python-pillow/Pillow/compare/10.0.1...10.2.0) --- updated-dependencies: - dependency-name: pillow dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- src/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/requirements.txt b/src/requirements.txt index 2f31838..fd655d9 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -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 From dfd3e5f61b858af6f5faf75a3e4f70a61598c92b Mon Sep 17 00:00:00 2001 From: Lucas Bubner Date: Wed, 24 Jan 2024 16:22:23 +1030 Subject: [PATCH 2/4] Undeprecate deprecated code --- src/auth.py | 4 ++-- src/img.py | 26 +++++++++++--------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/auth.py b/src/auth.py index 2592d42..69c7913 100644 --- a/src/auth.py +++ b/src/auth.py @@ -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.") @@ -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 diff --git a/src/img.py b/src/img.py index 2bb227d..6d2b208 100644 --- a/src/img.py +++ b/src/img.py @@ -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')}?code={event.get('checkin_code')}", 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": @@ -64,37 +60,37 @@ 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) + 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) @@ -193,11 +189,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 From eacd2bdec82a57015fc02dba8017583f45ca88ba Mon Sep 17 00:00:00 2001 From: Lucas Bubner Date: Wed, 24 Jan 2024 16:36:54 +1030 Subject: [PATCH 3/4] Fix QR from displaying checkin code on registration --- src/img.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/img.py b/src/img.py index 6d2b208..5ceb9cf 100644 --- a/src/img.py +++ b/src/img.py @@ -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')}?code={event.get('checkin_code')}", + 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, From a0a818b01e0350462922ec23484c50337c4b4c21 Mon Sep 17 00:00:00 2001 From: Lucas Bubner Date: Wed, 24 Jan 2024 16:49:33 +1030 Subject: [PATCH 4/4] Fix minor bugs with email and ci --- src/img.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/img.py b/src/img.py index 5ceb9cf..c2d35b9 100644 --- a/src/img.py +++ b/src/img.py @@ -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, @@ -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"))