-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add logic for the new registration (static) variables #3984
Conversation
Drop the dataclass, makes it confusing with field excluded from init, and the fact that the identifier needs to be specified again Use class vars instead Make use of newly added type alias
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3984 +/- ##
==========================================
- Coverage 96.11% 96.02% -0.10%
==========================================
Files 724 726 +2
Lines 22625 22753 +128
Branches 2607 2620 +13
==========================================
+ Hits 21747 21848 +101
- Misses 622 649 +27
Partials 256 256 ☔ View full report in Codecov by Sentry. |
b6d9596
to
01af7c6
Compare
…gins Update tests that where affected For the objects API, the `variables_registry` will be defined in the upcoming commits
Will be used by objects API registration variables
Define a new step, `save_registration_data`, that will populate the `ObjectsAPIRegistrationData`.
5481e98
to
44bca03
Compare
attachment_urls = ArrayField( | ||
models.URLField( | ||
_("attachment url"), help_text=_("The attachment URL on the Documents API.") | ||
), | ||
verbose_name=_("attachment urls"), | ||
help_text=_("The list of attachment URLs on the Documents API."), | ||
blank=True, | ||
default=list, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is too naive, you lose the information of which file/component the Document URL belongs too.
I'd still prefer to have the variable of a file upload explicitly mapped into the schema, e.g. something like:
type: object
properties:
proofOfEmployment:
type: string
format: uri
bankStatements:
type: array
items:
type: string
format: uri
so that you can make the (single) file upload "proof of employment" to /proofOfEmployment
and the multi-file upload "bank statements" to /bankStatements
Possibly we do this in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering this requires thinking and probably some work, it will probably be part of the next PR
src/openforms/registrations/contrib/objects_api/registration_variables.py
Outdated
Show resolved
Hide resolved
src/openforms/registrations/contrib/objects_api/submission_registration.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just need to fix CI :)
f1bf228
to
86401a6
Compare
After a lot of thinking about the technical implementation:
get_static_variables
was adapted so that it can iterate over a provided registry, instead of the default one for vanilla static variables.This preserves backward compatibility, as
get_static_variables([, submission=...])
will still use the default registry. It also works well this way becauseget_static_variables
is currently used in:open-forms/src/openforms/forms/api/validators.py
Lines 126 to 128 in bed8118
registration static variables shouldn't be referenced.
open-forms/src/openforms/forms/api/serializers/form_variable.py
Lines 54 to 55 in bed8118
Ideally registration variables should be taken into account as well. Not sure how common a name collision between a form variable and a registration variable would be. If we want to validate this, it might get tricky as every registration backend should be taken into account. So perhaps a new
include_registration
boolean option toget_static_variables
could be added? (Issue is it is conflicting with thevariables_registry
argument).get_variables_for_context
: ✅open-forms/src/openforms/variables/utils.py
Lines 52 to 56 in bed8118
get_variables_for_context
is only used for the Objects API (where it makes sense to not include reg. variables, those are added manually in the context by accessingObjectsAPIRegistrationData
) and the email backend (not sure about this one, probably doesn't make sense to have registration variables for this plugin anyway?).open-forms/src/openforms/variables/api/views.py
Lines 24 to 30 in bed8118
As expected, reg. variables are in a separate endpoint.
For tests,
I'm planning on testingI tested theObjectsAPIRegistrationData
creation, in particular how it behaves when I get an API error when trying to create documents. Not sure where to put these, ideally I don't want to touch the big 1k linesObjectsAPIBackendTests
test class, although it might require some refactor?Added registration variables will be tested in #3982, when the v2 registration will be tested.