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

Improve the code that creates submission attachments from files in submission data #2713

Open
SilviaAmAm opened this issue Feb 15, 2023 · 2 comments

Comments

@SilviaAmAm
Copy link
Contributor

SilviaAmAm commented Feb 15, 2023

Thema / Theme

API

Omschrijving / Description

The bandaid fix for this issue #2699 showed that the code for creating submission attachments by looking through the submission data and extracting any file is quite fragile.

This should be refactored into a more robust solution.

Aspects to take into account:

  • formio/rendering/default.py -> there's a lot of configuration/data path mangling/processing - this would benefit from normalization so we have a more simple interface
  • iterating over components with a context (key, config path, data path...)
  • untangle the path/json_renderer_path/configuration_path complexity in src/openforms/formio/rendering/nodes.py
@joeribekker
Copy link
Contributor

joeribekker commented Apr 29, 2024

Refinement: We don't know how to make it better but it should be. @Viicos can write down his proposal. Special attention is needed with editgrids.

@Viicos
Copy link
Contributor

Viicos commented May 3, 2024

Took a look at that part of the code-base: it seems closely related to #3154, in fact tackling this issue probably requires tackling the meta-issue.

I'm not sure how the formio.rendering module relates to the submission attachment creation however.

@sergei-maertens sergei-maertens self-assigned this Dec 21, 2024
sergei-maertens added a commit that referenced this issue Jan 29, 2025
Moved the file component key/value processing to the mapped variable
processing instead of special casing this in the registration handler,
since we will need access to the component types to handle editgrids
which have file uploads inside, as these have different data paths
*and* will require recursion as well since there can be editgrids
inside editgrids that have this problem.

The alternative is special casing repeating groups too, which breaks
the mechanism to do component-specific post-processing in the
dedicated function.

This also updates the query for the submission variables so that if we
have a more exact data path for an upload (inside a repeating group)
that we use that instead of messing with the container editgrid which
incorrectly gets replaced now. For uploads *not* in repeating groups,
this data path is empty because it's identical to the variable key,
so we can coalesce there at the DB level to calculate this in a
unified way.

See also #2713 that highlights the difficulties with how file uploads
are now processed, which requires some proper re-structuring.
sergei-maertens added a commit that referenced this issue Jan 30, 2025
Moved the file component key/value processing to the mapped variable
processing instead of special casing this in the registration handler,
since we will need access to the component types to handle editgrids
which have file uploads inside, as these have different data paths
*and* will require recursion as well since there can be editgrids
inside editgrids that have this problem.

The alternative is special casing repeating groups too, which breaks
the mechanism to do component-specific post-processing in the
dedicated function.

This also updates the query for the submission variables so that if we
have a more exact data path for an upload (inside a repeating group)
that we use that instead of messing with the container editgrid which
incorrectly gets replaced now. For uploads *not* in repeating groups,
this data path is empty because it's identical to the variable key,
so we can coalesce there at the DB level to calculate this in a
unified way.

See also #2713 that highlights the difficulties with how file uploads
are now processed, which requires some proper re-structuring.
sergei-maertens added a commit that referenced this issue Jan 31, 2025
Moved the file component key/value processing to the mapped variable
processing instead of special casing this in the registration handler,
since we will need access to the component types to handle editgrids
which have file uploads inside, as these have different data paths
*and* will require recursion as well since there can be editgrids
inside editgrids that have this problem.

The alternative is special casing repeating groups too, which breaks
the mechanism to do component-specific post-processing in the
dedicated function.

This also updates the query for the submission variables so that if we
have a more exact data path for an upload (inside a repeating group)
that we use that instead of messing with the container editgrid which
incorrectly gets replaced now. For uploads *not* in repeating groups,
this data path is empty because it's identical to the variable key,
so we can coalesce there at the DB level to calculate this in a
unified way.

See also #2713 that highlights the difficulties with how file uploads
are now processed, which requires some proper re-structuring.
sergei-maertens added a commit that referenced this issue Jan 31, 2025
Moved the file component key/value processing to the mapped variable
processing instead of special casing this in the registration handler,
since we will need access to the component types to handle editgrids
which have file uploads inside, as these have different data paths
*and* will require recursion as well since there can be editgrids
inside editgrids that have this problem.

The alternative is special casing repeating groups too, which breaks
the mechanism to do component-specific post-processing in the
dedicated function.

This also updates the query for the submission variables so that if we
have a more exact data path for an upload (inside a repeating group)
that we use that instead of messing with the container editgrid which
incorrectly gets replaced now. For uploads *not* in repeating groups,
this data path is empty because it's identical to the variable key,
so we can coalesce there at the DB level to calculate this in a
unified way.

See also #2713 that highlights the difficulties with how file uploads
are now processed, which requires some proper re-structuring.

We must look up the uploads in the url map and replace only the
file component nodes in the item values rather than the whole
repeating group. This also needs to recurse, since in theory
the repeating group can have another repeating group inside
it.

Backport-of: #5059
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

4 participants