From c911f0bea0b2cc72c84b49b77d49fdf58c12e5e5 Mon Sep 17 00:00:00 2001 From: Viktor van Wijk Date: Fri, 20 Dec 2024 11:21:27 +0100 Subject: [PATCH] :art: [#4908] Remove check if attachment queryset exists This check if redundant, as the for loop will never be executed anyway if the query set is empty --- .../registrations/contrib/json/plugin.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/openforms/registrations/contrib/json/plugin.py b/src/openforms/registrations/contrib/json/plugin.py index 26384af938..9a6772eea4 100644 --- a/src/openforms/registrations/contrib/json/plugin.py +++ b/src/openforms/registrations/contrib/json/plugin.py @@ -27,14 +27,13 @@ def register_submission(self, submission: Submission, options: JSONRegistrationO values = {} # Encode (base64) and add attachments to values dict if their form keys were specified in the # form variables list - if submission.attachments.exists(): - for attachment in submission.attachments: - if not attachment.form_key in options["form_variables"]: - continue - options["form_variables"].remove(attachment.form_key) - with attachment.content.open("rb") as f: - f.seek(0) - values[attachment.form_key] = base64.b64encode(f.read()).decode() + for attachment in submission.attachments: + if not attachment.form_key in options["form_variables"]: + continue + options["form_variables"].remove(attachment.form_key) + with attachment.content.open("rb") as f: + f.seek(0) + values[attachment.form_key] = base64.b64encode(f.read()).decode() # Create static variables dict static_variables = get_static_variables(submission=submission)