-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#4396] Added the attributes retrival functionality
This is not the whole prefill plugin functionality. This commit handles the procedures in order to be able to send to the frontend the available attributes (for mapping the form variable with the objecttype attribute) depending on the selected objecttype's version.
- Loading branch information
Showing
13 changed files
with
442 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import TYPE_CHECKING, Required, TypedDict | ||
|
||
if TYPE_CHECKING: | ||
from openforms.registrations.contrib.objects_api.models import ObjectsAPIGroupConfig | ||
|
||
|
||
class _BasePrefillOptions(TypedDict): | ||
prefill_plugin: str | ||
|
||
|
||
class ObjecttypeVariableMapping(TypedDict): | ||
variable_key: str | ||
target_path: list[str] | ||
|
||
|
||
class ObjectsAPIPrefillOptions(_BasePrefillOptions): | ||
objects_api_group: Required[ObjectsAPIGroupConfig] | ||
objecttype_uuid: Required[str] | ||
objecttype_version: Required[int] | ||
variables_mapping: Required[list[ObjecttypeVariableMapping]] | ||
20 changes: 20 additions & 0 deletions
20
src/openforms/forms/migrations/0098_formvariable_prefill_options.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Generated by Django 4.2.15 on 2024-08-21 11:04 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("forms", "0097_v267_to_v270"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="formvariable", | ||
name="prefill_options", | ||
field=models.JSONField( | ||
blank=True, default=dict, verbose_name="prefill options" | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
.../ObjectsAPIPrefillPluginTests/ObjectsAPIPrefillPluginTests.test_available_attributes.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- '*/*' | ||
Accept-Encoding: | ||
- gzip, deflate, br | ||
Authorization: | ||
- Token 171be5abaf41e7856b423ad513df1ef8f867ff48 | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- python-requests/2.32.2 | ||
method: GET | ||
uri: http://localhost:8001/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48/versions/3 | ||
response: | ||
body: | ||
string: '{"url":"http://objecttypes-web:8000/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48/versions/3","version":3,"objectType":"http://objecttypes-web:8000/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48","status":"draft","jsonSchema":{"$id":"https://example.com/person.schema.json","type":"object","title":"Person","$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"age":{"type":"integer","minimum":18},"name":{"type":"object","properties":{"last.name":{"type":"string"}}},"nested":{"type":"object","properties":{"unrelated":{"type":"string"},"submission_payment_amount":{"type":"number","multipleOf":0.01}}},"submission_date":{"type":"string","format":"date-time"},"submission_csv_url":{"type":"string","format":"uri"},"submission_pdf_url":{"type":"string","format":"uri"},"submission_payment_completed":{"type":"boolean"},"submission_payment_public_ids":{"type":"array"}}},"createdAt":"2024-02-08","modifiedAt":"2024-02-08","publishedAt":"2024-02-08"}' | ||
headers: | ||
Allow: | ||
- GET, PUT, PATCH, DELETE, HEAD, OPTIONS | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '985' | ||
Content-Type: | ||
- application/json | ||
Cross-Origin-Opener-Policy: | ||
- same-origin | ||
Date: | ||
- Wed, 28 Aug 2024 08:04:23 GMT | ||
Referrer-Policy: | ||
- same-origin | ||
Server: | ||
- nginx/1.27.0 | ||
Vary: | ||
- origin | ||
X-Content-Type-Options: | ||
- nosniff | ||
X-Frame-Options: | ||
- DENY | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
Oops, something went wrong.