Skip to content

Commit

Permalink
🎨 [#4908] Remove check if attachment queryset exists
Browse files Browse the repository at this point in the history
This check if redundant, as the for loop will never be executed anyway if the query set is empty
  • Loading branch information
viktorvanwijk committed Dec 20, 2024
1 parent 4ed04a4 commit c911f0b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/openforms/registrations/contrib/json/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c911f0b

Please sign in to comment.