-
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.
✨ [#4789] ConfigurationStep for ZGW API registration config
this step relies on the previously added ServiceConfigurationStep and can be used to set up the necessary configuration for the ZGW API registration backend
- Loading branch information
Showing
11 changed files
with
457 additions
and
12 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
13 changes: 1 addition & 12 deletions
13
src/openforms/contrib/objects_api/setup_configuration/steps.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
Empty file.
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,48 @@ | ||
from django_setup_configuration.fields import DjangoModelRef | ||
from django_setup_configuration.models import ConfigurationModel | ||
from pydantic import Field | ||
|
||
from openforms.registrations.contrib.zgw_apis.models import ZGWApiGroupConfig | ||
|
||
|
||
class SingleZGWApiGroupConfigModel(ConfigurationModel): | ||
zaken_service_identifier: str = DjangoModelRef(ZGWApiGroupConfig, "zrc_service") | ||
documenten_service_identifier: str = DjangoModelRef( | ||
ZGWApiGroupConfig, | ||
"drc_service", | ||
) | ||
catalogi_service_identifier: str = DjangoModelRef( | ||
ZGWApiGroupConfig, | ||
"ztc_service", | ||
) | ||
|
||
# Slightly more descriptive name | ||
objects_api_json_content_template: str = DjangoModelRef( | ||
ZGWApiGroupConfig, "content_json" | ||
) | ||
|
||
# FIXME choices and blank=True doesn't seem to be picked up properly | ||
zaak_vertrouwelijkheidaanduiding: str = DjangoModelRef( | ||
ZGWApiGroupConfig, | ||
"zaak_vertrouwelijkheidaanduiding", | ||
default="", | ||
) | ||
doc_vertrouwelijkheidaanduiding: str = DjangoModelRef( | ||
ZGWApiGroupConfig, "doc_vertrouwelijkheidaanduiding", default="" | ||
) | ||
|
||
class Meta: | ||
django_model_refs = { | ||
ZGWApiGroupConfig: [ | ||
"name", | ||
"identifier", | ||
"catalogue_domain", | ||
"catalogue_rsin", | ||
"organisatie_rsin", | ||
"auteur", | ||
] | ||
} | ||
|
||
|
||
class ZGWApiGroupConfigModel(ConfigurationModel): | ||
groups: list[SingleZGWApiGroupConfigModel] = Field(default_factory=list) |
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,42 @@ | ||
from django_setup_configuration.configuration import BaseConfigurationStep | ||
|
||
from openforms.registrations.contrib.zgw_apis.models import ZGWApiGroupConfig | ||
from openforms.utils.services import get_service | ||
|
||
from .models import SingleZGWApiGroupConfigModel, ZGWApiGroupConfigModel | ||
|
||
|
||
class ZGWApiConfigurationStep(BaseConfigurationStep[ZGWApiGroupConfigModel]): | ||
""" | ||
Configure configuration groups for the ZGW API backend | ||
""" | ||
|
||
verbose_name = "Configuration to set up ZGW API registration backend services" | ||
config_model = ZGWApiGroupConfigModel | ||
namespace = "zgw_api" | ||
enable_setting = "zgw_api_config_enable" | ||
|
||
def execute(self, model: ZGWApiGroupConfigModel): | ||
config: SingleZGWApiGroupConfigModel | ||
for config in model.groups: | ||
# setup_configuration typing doesn't work for `django_model_refs` yet, | ||
# hence the type: ignores | ||
# (https://github.com/maykinmedia/django-setup-configuration/issues/25) | ||
defaults = { | ||
"name": config.name, # type: ignore | ||
"zrc_service": get_service(config.zaken_service_identifier), | ||
"drc_service": get_service(config.documenten_service_identifier), | ||
"ztc_service": get_service(config.catalogi_service_identifier), | ||
"catalogue_domain": config.catalogue_domain, # type: ignore | ||
"catalogue_rsin": config.catalogue_rsin, # type: ignore | ||
"organisatie_rsin": config.organisatie_rsin, # type: ignore | ||
"zaak_vertrouwelijkheidaanduiding": config.zaak_vertrouwelijkheidaanduiding, | ||
"doc_vertrouwelijkheidaanduiding": config.doc_vertrouwelijkheidaanduiding, | ||
"auteur": config.auteur, # type: ignore | ||
"content_json": config.objects_api_json_content_template, | ||
} | ||
|
||
ZGWApiGroupConfig.objects.update_or_create( | ||
identifier=config.identifier, | ||
defaults=defaults, | ||
) |
Empty file.
32 changes: 32 additions & 0 deletions
32
src/openforms/contrib/zgw/setup_configuration/tests/files/setup_config.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,32 @@ | ||
zgw_api_config_enable: True | ||
zgw_api: | ||
groups: | ||
- name: Config 1 | ||
identifier: config-1 | ||
zaken_service_identifier: zaken-test | ||
documenten_service_identifier: documenten-test | ||
catalogi_service_identifier: catalogi-test | ||
catalogue_domain: TEST | ||
catalogue_rsin: "000000000" | ||
organisatie_rsin: "000000000" | ||
zaak_vertrouwelijkheidaanduiding: zaakvertrouwelijk | ||
doc_vertrouwelijkheidaanduiding: openbaar | ||
auteur: John Doe | ||
objects_api_json_content_template: | | ||
{ | ||
"data": {% json_summary %}, | ||
"type": "{{ productaanvraag_type }}", | ||
"bsn": "{{ variables.auth_bsn }}", | ||
"submission_id": "{{ submission.kenmerk }}", | ||
"language_code": "{{ submission.language_code }}", | ||
"custom_field": "foo" | ||
} | ||
- name: Config 2 | ||
identifier: config-2 | ||
zaken_service_identifier: zaken-test | ||
documenten_service_identifier: documenten-test | ||
catalogi_service_identifier: catalogi-test | ||
catalogue_domain: OTHER | ||
catalogue_rsin: "000000000" | ||
organisatie_rsin: "000000000" | ||
auteur: Jane Doe |
23 changes: 23 additions & 0 deletions
23
src/openforms/contrib/zgw/setup_configuration/tests/files/setup_config_all_fields.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,23 @@ | ||
zgw_api_config_enable: True | ||
zgw_api: | ||
groups: | ||
- name: Config 1 | ||
identifier: config-1 | ||
zaken_service_identifier: zaken-test | ||
documenten_service_identifier: documenten-test | ||
catalogi_service_identifier: catalogi-test | ||
catalogue_domain: TEST | ||
catalogue_rsin: "000000000" | ||
organisatie_rsin: "000000000" | ||
zaak_vertrouwelijkheidaanduiding: zaakvertrouwelijk | ||
doc_vertrouwelijkheidaanduiding: openbaar | ||
auteur: John Doe | ||
objects_api_json_content_template: | | ||
{ | ||
"data": {% json_summary %}, | ||
"type": "{{ productaanvraag_type }}", | ||
"bsn": "{{ variables.auth_bsn }}", | ||
"submission_id": "{{ submission.kenmerk }}", | ||
"language_code": "{{ submission.language_code }}", | ||
"custom_field": "foo" | ||
} |
9 changes: 9 additions & 0 deletions
9
src/openforms/contrib/zgw/setup_configuration/tests/files/setup_config_required_fields.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,9 @@ | ||
zgw_api_config_enable: True | ||
zgw_api: | ||
groups: | ||
- name: Config 1 | ||
identifier: config-1 | ||
zaken_service_identifier: zaken-test | ||
documenten_service_identifier: documenten-test | ||
catalogi_service_identifier: catalogi-test | ||
auteur: Jane Doe |
Oops, something went wrong.