From a3f847f4f806952e5a0d8b21db02c022b24e584f Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Mon, 11 Nov 2024 08:46:58 +0100 Subject: [PATCH 01/18] :wastebasket: [#4606] Deprecate ZGW url-based document type configuration --- .../form_design/registrations/zgw/ZGWOptionsFormFields.js | 4 ++-- .../zgw/fields/{DocumentType.js => LegacyDocumentType.js} | 8 ++++---- .../admin/form_design/registrations/zgw/fields/index.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/openforms/js/components/admin/form_design/registrations/zgw/fields/{DocumentType.js => LegacyDocumentType.js} (84%) diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.js b/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.js index 9c9bf07049..bfad86df5a 100644 --- a/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.js +++ b/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.js @@ -17,7 +17,7 @@ import {ObjectsAPIGroup} from 'components/admin/forms/objects_api'; import BasicOptionsFieldset from './BasicOptionsFieldset'; import ManageVariableToPropertyMappings from './ManageVariableToPropertyMappings'; import OptionalOptionsFieldset from './OptionalOptionsFieldset'; -import {DocumentType, LegacyCaseType, ObjectType, ObjectTypeVersion} from './fields'; +import {LegacyCaseType, LegacyDocumentType, ObjectType, ObjectTypeVersion} from './fields'; /** * Callback to invoke when the API group changes - used to reset the dependent fields. @@ -86,7 +86,7 @@ const ZGWFormFields = ({ /> - + diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/fields/DocumentType.js b/src/openforms/js/components/admin/form_design/registrations/zgw/fields/LegacyDocumentType.js similarity index 84% rename from src/openforms/js/components/admin/form_design/registrations/zgw/fields/DocumentType.js rename to src/openforms/js/components/admin/form_design/registrations/zgw/fields/LegacyDocumentType.js index bad5127248..e0bdaf2c63 100644 --- a/src/openforms/js/components/admin/form_design/registrations/zgw/fields/DocumentType.js +++ b/src/openforms/js/components/admin/form_design/registrations/zgw/fields/LegacyDocumentType.js @@ -6,9 +6,9 @@ import FormRow from 'components/admin/forms/FormRow'; import {TextInput} from 'components/admin/forms/Inputs'; /** - * @todo - convert to omschrijving & use URL-based field as legacy/deprecated option + * @deprecated */ -const DocumentType = () => { +const LegacyDocumentType = () => { const [fieldProps] = useField('informatieobjecttype'); return ( @@ -34,6 +34,6 @@ const DocumentType = () => { ); }; -DocumentType.propTypes = {}; +LegacyDocumentType.propTypes = {}; -export default DocumentType; +export default LegacyDocumentType; diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/fields/index.js b/src/openforms/js/components/admin/form_design/registrations/zgw/fields/index.js index f439506511..6bf73d3d7b 100644 --- a/src/openforms/js/components/admin/form_design/registrations/zgw/fields/index.js +++ b/src/openforms/js/components/admin/form_design/registrations/zgw/fields/index.js @@ -2,7 +2,7 @@ export {default as ZGWAPIGroup} from './ZGWAPIGroup'; export {default as CatalogueSelect} from './CatalogueSelect'; export {default as CaseTypeSelect} from './CaseTypeSelect'; export {default as LegacyCaseType} from './LegacyCaseType'; -export {default as DocumentType} from './DocumentType'; +export {default as LegacyDocumentType} from './LegacyDocumentType'; export {default as OrganisationRSIN} from './OrganisationRSIN'; export {default as ConfidentialityLevel} from './ConfidentialityLevel'; export {default as MedewerkerRoltype} from './MedewerkerRoltype'; From 5297cfdd4ad7a5c8b99eac8e23db72bb0ab68338 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Mon, 11 Nov 2024 09:44:17 +0100 Subject: [PATCH 02/18] :sparkles: [#4606] Implement frontend to select document type from case type Once a case type is selected, the available document type options are fetched from the backend and we only store the 'description' field value in the configuration options. --- src/openforms/js/compiled-lang/en.json | 12 ++ src/openforms/js/compiled-lang/nl.json | 12 ++ .../registrations/zgw/BasicOptionsFieldset.js | 53 +++++++- .../registrations/zgw/ZGWOptionsForm.js | 1 + .../registrations/zgw/ZGWOptionsFormFields.js | 3 + .../zgw/ZGWOptionsFormFields.stories.js | 11 +- .../zgw/fields/CaseTypeSelect.js | 3 +- .../zgw/fields/DocumentTypeSelect.js | 122 ++++++++++++++++++ .../zgw/fields/LegacyCaseType.js | 2 +- .../zgw/fields/LegacyDocumentType.js | 7 +- .../registrations/zgw/fields/ZGWAPIGroup.js | 2 + .../registrations/zgw/fields/index.js | 1 + .../form_design/registrations/zgw/mocks.js | 62 +++++++++ src/openforms/js/lang/en.json | 10 ++ src/openforms/js/lang/nl.json | 10 ++ 15 files changed, 298 insertions(+), 13 deletions(-) create mode 100644 src/openforms/js/components/admin/form_design/registrations/zgw/fields/DocumentTypeSelect.js diff --git a/src/openforms/js/compiled-lang/en.json b/src/openforms/js/compiled-lang/en.json index 40638e9338..7773ec7631 100644 --- a/src/openforms/js/compiled-lang/en.json +++ b/src/openforms/js/compiled-lang/en.json @@ -1395,6 +1395,12 @@ "value": "Data extraction" } ], + "C2FSDV": [ + { + "type": 0, + "value": "Documents produced in the form submission are registered with this document type, unless more fine grained configuration is available. Only document types available on the selected case type are shown." + } + ], "C48xJT": [ { "type": 0, @@ -2641,6 +2647,12 @@ "value": "Case type API resource URL in the Catalogi API." } ], + "NrF5vy": [ + { + "type": 0, + "value": "Document type" + } + ], "Nsifca": [ { "type": 0, diff --git a/src/openforms/js/compiled-lang/nl.json b/src/openforms/js/compiled-lang/nl.json index 4d40c08e71..050007675e 100644 --- a/src/openforms/js/compiled-lang/nl.json +++ b/src/openforms/js/compiled-lang/nl.json @@ -1399,6 +1399,12 @@ "value": "Gegevensverwerking" } ], + "C2FSDV": [ + { + "type": 0, + "value": "Documents produced in the form submission are registered with this document type, unless more fine grained configuration is available. Only document types available on the selected case type are shown." + } + ], "C48xJT": [ { "type": 0, @@ -2662,6 +2668,12 @@ "value": "Zaaktype-API-resource URL in de Catalogi-API." } ], + "NrF5vy": [ + { + "type": 0, + "value": "Document type" + } + ], "Nsifca": [ { "type": 0, diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/BasicOptionsFieldset.js b/src/openforms/js/components/admin/form_design/registrations/zgw/BasicOptionsFieldset.js index b8ca8e6715..3744042439 100644 --- a/src/openforms/js/components/admin/form_design/registrations/zgw/BasicOptionsFieldset.js +++ b/src/openforms/js/components/admin/form_design/registrations/zgw/BasicOptionsFieldset.js @@ -1,14 +1,14 @@ import {useFormikContext} from 'formik'; import PropTypes from 'prop-types'; -import {FormattedMessage} from 'react-intl'; -import {useAsync} from 'react-use'; +import {FormattedMessage, useIntl} from 'react-intl'; +import {useAsync, usePrevious, useUpdateEffect} from 'react-use'; import useConfirm from 'components/admin/form_design/useConfirm'; import Fieldset from 'components/admin/forms/Fieldset'; import {getCatalogueOption} from 'components/admin/forms/zgw'; import ErrorBoundary from 'components/errors/ErrorBoundary'; -import {CaseTypeSelect, CatalogueSelect, ZGWAPIGroup} from './fields'; +import {CaseTypeSelect, CatalogueSelect, DocumentTypeSelect, ZGWAPIGroup} from './fields'; import {getCatalogues} from './utils'; // Components @@ -16,6 +16,8 @@ import {getCatalogues} from './utils'; const BasicOptionsFieldset = ({apiGroupChoices}) => { const { values: { + caseTypeIdentification, + documentTypeDescription, zaaktype, informatieobjecttype, medewerkerRoltype, @@ -28,6 +30,8 @@ const BasicOptionsFieldset = ({apiGroupChoices}) => { const hasAnyFieldConfigured = [ + caseTypeIdentification, + documentTypeDescription, zaaktype, informatieobjecttype, medewerkerRoltype, @@ -86,9 +90,19 @@ BasicOptionsFieldset.propTypes = { const CatalogiApiFields = () => { const { - values: {zgwApiGroup = null, catalogue = undefined}, + values: { + zgwApiGroup = null, + catalogue = undefined, + caseTypeIdentification = '', + documentTypeDescription = '', + productUrl = '', + }, + setFieldValue, } = useFormikContext(); + const previousCatalogue = usePrevious(catalogue); + const previousCaseTypeIdentification = usePrevious(caseTypeIdentification); + // fetch available catalogues and re-use the result const { loading: loadingCatalogues, @@ -103,12 +117,41 @@ const CatalogiApiFields = () => { const catalogueValue = getCatalogueOption(catalogueOptionGroups, catalogue || {}); const catalogueUrl = catalogueValue?.url; - // TODO: if the catalogue changes, reset the select case type + // Synchronize dependent fields when dependencies change. + // 1. Clear case type when catalogue changes. + useUpdateEffect(() => { + const catalogueChanged = catalogue !== previousCatalogue; + if (previousCatalogue && catalogueChanged && caseTypeIdentification) { + setFieldValue('caseTypeIdentification', ''); + } + }, [setFieldValue, previousCatalogue, catalogue, caseTypeIdentification]); + + // 2. Clear document type when case type changes + useUpdateEffect(() => { + const caseTypeChanged = caseTypeIdentification !== previousCaseTypeIdentification; + if (previousCaseTypeIdentification && caseTypeChanged && documentTypeDescription) { + setFieldValue('documentTypeDescription', ''); + } + }, [ + setFieldValue, + previousCaseTypeIdentification, + caseTypeIdentification, + documentTypeDescription, + ]); + + // 3. Clear selected product when case type changes + useUpdateEffect(() => { + const caseTypeChanged = caseTypeIdentification !== previousCaseTypeIdentification; + if (previousCaseTypeIdentification && caseTypeChanged && productUrl) { + setFieldValue('productUrl', ''); + } + }, [setFieldValue, previousCaseTypeIdentification, caseTypeIdentification, productUrl]); return ( <> + ); }; diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsForm.js b/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsForm.js index bbd5cb2dbc..978fc0e9b3 100644 --- a/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsForm.js +++ b/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsForm.js @@ -39,6 +39,7 @@ const ZGWOptionsForm = ({name, label, schema, formData, onChange}) => { initialFormData={{ // defaults caseTypeIdentification: '', + documentTypeDescription: '', zaaktype: '', informatieobjecttype: '', organisatieRsin: '', diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.js b/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.js index bfad86df5a..c43929489a 100644 --- a/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.js +++ b/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.js @@ -68,6 +68,7 @@ const ZGWFormFields = ({ + {/* @deprecated */}
} + fieldNames={['zaaktype', 'informatieobjecttype']} + collapsible >
{ }; const CaseTypeSelect = ({catalogueUrl = ''}) => { - const [fieldProps, , fieldHelpers] = useField('caseTypeIdentification'); + const [, , fieldHelpers] = useField('caseTypeIdentification'); const { values: {zgwApiGroup = null}, } = useFormikContext(); - const {value} = fieldProps; const {setValue} = fieldHelpers; const { diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/fields/DocumentTypeSelect.js b/src/openforms/js/components/admin/form_design/registrations/zgw/fields/DocumentTypeSelect.js new file mode 100644 index 0000000000..86e3cb6a02 --- /dev/null +++ b/src/openforms/js/components/admin/form_design/registrations/zgw/fields/DocumentTypeSelect.js @@ -0,0 +1,122 @@ +import classNames from 'classnames'; +import {useField, useFormikContext} from 'formik'; +import PropTypes from 'prop-types'; +import React from 'react'; +import {FormattedMessage} from 'react-intl'; +import {components} from 'react-select'; +import useAsync from 'react-use/esm/useAsync'; + +import Field from 'components/admin/forms/Field'; +import FormRow from 'components/admin/forms/FormRow'; +import ReactSelect from 'components/admin/forms/ReactSelect'; +import {get} from 'utils/fetch'; + +/** + * @todo Implement on the backend + */ +const DOCUMENT_TYPES_ENDPOINT = '/api/v2/registration/plugins/zgw-api/document-types'; + +const getAvailableDocumentTypes = async (apiGroupID, catalogueUrl, caseTypeIdentification) => { + const response = await get(DOCUMENT_TYPES_ENDPOINT, { + zgw_api_group: apiGroupID, + catalogue_url: catalogueUrl, + case_type_identification: caseTypeIdentification, + }); + if (!response.ok) { + throw new Error('Loading available object types failed'); + } + const documentTypes = response.data.sort((a, b) => a.description.localeCompare(b.description)); + return documentTypes.map(({description, isPublished}) => ({ + value: description, + label: description, + isPublished: isPublished, + })); +}; + +// Components + +const DocumentTypeSelectOption = props => { + const {isPublished, label} = props.data; + return ( + + + (not published)} other {}}`} + values={{ + label, + isPublished, + draft: chunks => {chunks}, + }} + /> + + + ); +}; + +const DocumentTypeSelect = ({catalogueUrl = ''}) => { + const [, , fieldHelpers] = useField('documentTypeDescription'); + const { + values: {zgwApiGroup = null, caseTypeIdentification = ''}, + } = useFormikContext(); + const {setValue} = fieldHelpers; + + const { + loading, + value: documentTypes = [], + error, + } = useAsync(async () => { + if (!zgwApiGroup || !catalogueUrl || !caseTypeIdentification) return []; + return await getAvailableDocumentTypes(zgwApiGroup, catalogueUrl, caseTypeIdentification); + }, [zgwApiGroup, catalogueUrl, caseTypeIdentification]); + if (error) throw error; + + return ( + + + } + helpText={ + + } + noManageChildProps + > + { + setValue(selectedOption ? selectedOption.value : undefined); + }} + /> + + + ); +}; + +DocumentTypeSelect.propTypes = { + catalogueUrl: PropTypes.string, +}; + +export default DocumentTypeSelect; diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/fields/LegacyCaseType.js b/src/openforms/js/components/admin/form_design/registrations/zgw/fields/LegacyCaseType.js index c0d6b7e6ab..72884f4071 100644 --- a/src/openforms/js/components/admin/form_design/registrations/zgw/fields/LegacyCaseType.js +++ b/src/openforms/js/components/admin/form_design/registrations/zgw/fields/LegacyCaseType.js @@ -6,7 +6,7 @@ import FormRow from 'components/admin/forms/FormRow'; import {TextInput} from 'components/admin/forms/Inputs'; /** - * @todo - convert to omschrijving & use URL-based field as legacy/deprecated option + * @deprecated */ const CaseType = () => { const [fieldProps] = useField('zaaktype'); diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/fields/LegacyDocumentType.js b/src/openforms/js/components/admin/form_design/registrations/zgw/fields/LegacyDocumentType.js index e0bdaf2c63..2301b169da 100644 --- a/src/openforms/js/components/admin/form_design/registrations/zgw/fields/LegacyDocumentType.js +++ b/src/openforms/js/components/admin/form_design/registrations/zgw/fields/LegacyDocumentType.js @@ -1,4 +1,4 @@ -import {useField} from 'formik'; +import {useField, useFormikContext} from 'formik'; import {FormattedMessage} from 'react-intl'; import Field from 'components/admin/forms/Field'; @@ -10,11 +10,14 @@ import {TextInput} from 'components/admin/forms/Inputs'; */ const LegacyDocumentType = () => { const [fieldProps] = useField('informatieobjecttype'); + const { + values: {documentTypeDescription}, + } = useFormikContext(); return ( { useUpdateEffect(() => { setValues(prevValues => ({ ...prevValues, + caseTypeIdentification: '', + documentTypeDescription: '', zaaktype: '', informatieobjecttype: '', medewerkerRoltype: '', diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/fields/index.js b/src/openforms/js/components/admin/form_design/registrations/zgw/fields/index.js index 6bf73d3d7b..424411d427 100644 --- a/src/openforms/js/components/admin/form_design/registrations/zgw/fields/index.js +++ b/src/openforms/js/components/admin/form_design/registrations/zgw/fields/index.js @@ -1,6 +1,7 @@ export {default as ZGWAPIGroup} from './ZGWAPIGroup'; export {default as CatalogueSelect} from './CatalogueSelect'; export {default as CaseTypeSelect} from './CaseTypeSelect'; +export {default as DocumentTypeSelect} from './DocumentTypeSelect'; export {default as LegacyCaseType} from './LegacyCaseType'; export {default as LegacyDocumentType} from './LegacyDocumentType'; export {default as OrganisationRSIN} from './OrganisationRSIN'; diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/mocks.js b/src/openforms/js/components/admin/form_design/registrations/zgw/mocks.js index 3ff0ed7194..4ec17ae0ee 100644 --- a/src/openforms/js/components/admin/form_design/registrations/zgw/mocks.js +++ b/src/openforms/js/components/admin/form_design/registrations/zgw/mocks.js @@ -80,6 +80,68 @@ export const mockCaseTypesGet = () => return res(ctx.json(match)); }); +const DOCUMENT_TYPES = { + ZT01: [ + { + description: 'Attachment', + isPublished: true, + }, + { + description: 'Picture or scan of passport/identity card', + isPublished: true, + }, + ], + ZT02: [ + { + description: 'Attachment', + isPublished: true, + }, + { + description: 'Other', + isPublished: true, + }, + ], + ZT03: [], + ZT11: [ + { + description: 'Attachment', + isPublished: true, + }, + ], + ZT21: [ + { + description: 'Attachment', + isPublished: true, + }, + ], + ZT22: [ + { + description: 'Draft document type for draft case type', + isPublished: false, + }, + { + description: 'Published document type for draft case type', + isPublished: true, + }, + ], + ZT23: [ + { + description: 'Attachment', + isPublished: true, + }, + ], +}; + +export const mockDocumenTypesGet = () => + rest.get( + `${API_BASE_URL}/api/v2/registration/plugins/zgw-api/document-types`, + (req, res, ctx) => { + const caseTypeIdentification = req.url.searchParams.get('case_type_identification'); + const match = DOCUMENT_TYPES[caseTypeIdentification] ?? []; + return res(ctx.json(match)); + } + ); + const PRODUCTS = [ { uri: 'https://example.com/product/1234', diff --git a/src/openforms/js/lang/en.json b/src/openforms/js/lang/en.json index 38001cbf2d..a1cae37ddc 100644 --- a/src/openforms/js/lang/en.json +++ b/src/openforms/js/lang/en.json @@ -624,6 +624,11 @@ "description": "Service fetch configuration modal data extraction fieldset title", "originalDefault": "Data extraction" }, + "C2FSDV": { + "defaultMessage": "Documents produced in the form submission are registered with this document type, unless more fine grained configuration is available. Only document types available on the selected case type are shown.", + "description": "ZGW APIs registration options 'document type' helpText", + "originalDefault": "Documents produced in the form submission are registered with this document type, unless more fine grained configuration is available. Only document types available on the selected case type are shown." + }, "C4Zn+R": { "defaultMessage": "Internal name of the form definition used in this form step", "description": "Form step internal name field help text", @@ -1304,6 +1309,11 @@ "description": "ZGW APIs registration options 'CaseType' help text", "originalDefault": "Case type API resource URL in the Catalogi API." }, + "NrF5vy": { + "defaultMessage": "Document type", + "description": "ZGW APIs registration options 'document type' label", + "originalDefault": "Document type" + }, "NwTdLM": { "defaultMessage": "Component where locations for an appointment will be shown", "description": "Locations Component field help text", diff --git a/src/openforms/js/lang/nl.json b/src/openforms/js/lang/nl.json index caa8dd6243..a68e17f65c 100644 --- a/src/openforms/js/lang/nl.json +++ b/src/openforms/js/lang/nl.json @@ -629,6 +629,11 @@ "description": "Service fetch configuration modal data extraction fieldset title", "originalDefault": "Data extraction" }, + "C2FSDV": { + "defaultMessage": "Documents produced in the form submission are registered with this document type, unless more fine grained configuration is available. Only document types available on the selected case type are shown.", + "description": "ZGW APIs registration options 'document type' helpText", + "originalDefault": "Documents produced in the form submission are registered with this document type, unless more fine grained configuration is available. Only document types available on the selected case type are shown." + }, "C4Zn+R": { "defaultMessage": "Interne naam van de formulierdefinitie voor deze stap", "description": "Form step internal name field help text", @@ -1312,6 +1317,11 @@ "description": "ZGW APIs registration options 'CaseType' help text", "originalDefault": "Case type API resource URL in the Catalogi API." }, + "NrF5vy": { + "defaultMessage": "Document type", + "description": "ZGW APIs registration options 'document type' label", + "originalDefault": "Document type" + }, "NwTdLM": { "defaultMessage": "Veld waar beschikbare locaties voor een afspraak komen te staan", "description": "Locations Component field help text", From 5bbfb762b62cd2f30327e5f8bbe0e3a048a5a438 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Mon, 11 Nov 2024 17:44:50 +0100 Subject: [PATCH 03/18] :sparkles: [#4606] Add ZGW config option for document type Added the serializer option to specify a document type via its description, rather than having to provide a fully qualified URL. --- .../registrations/contrib/zgw_apis/options.py | 12 ++++++++++++ .../registrations/contrib/zgw_apis/typing.py | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/openforms/registrations/contrib/zgw_apis/options.py b/src/openforms/registrations/contrib/zgw_apis/options.py index 4e2fe81ac9..e5ab376a40 100644 --- a/src/openforms/registrations/contrib/zgw_apis/options.py +++ b/src/openforms/registrations/contrib/zgw_apis/options.py @@ -73,6 +73,18 @@ class ZaakOptionsSerializer(JsonSchemaSerializerMixin, serializers.Serializer): ), default="", ) + document_type_description = serializers.CharField( + required=False, # either htis field or informatieobjecttype (legacy) must be provided + label=_("Document type description"), + help_text=_( + "The document type will be retrived in the specified catalogue. The version " + "will automatically be selected based on the submission completion " + "timestamp. When you specify this field, you MUST also specify the case " + "type via its identification. Only document types related to the case type " + "are valid." + ), + default="", + ) product_url = serializers.URLField( required=False, label=_("Product url"), diff --git a/src/openforms/registrations/contrib/zgw_apis/typing.py b/src/openforms/registrations/contrib/zgw_apis/typing.py index cc4761944c..7809f0610d 100644 --- a/src/openforms/registrations/contrib/zgw_apis/typing.py +++ b/src/openforms/registrations/contrib/zgw_apis/typing.py @@ -34,9 +34,10 @@ class RegistrationOptions(TypedDict): zgw_api_group: ZGWApiGroupConfig catalogue: NotRequired[CatalogueOption] case_type_identification: str + document_type_description: str product_url: str # URL reference to a product in the case type zaaktype: str # DeprecationWarning - informatieobjecttype: str + informatieobjecttype: str # DeprecationWarning organisatie_rsin: NotRequired[str] zaak_vertrouwelijkheidaanduiding: NotRequired[VertrouwelijkheidAanduiding] medewerker_roltype: NotRequired[str] From c3937c152d25c0647a49d81c08f6be2b00dc6826 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Mon, 11 Nov 2024 17:50:54 +0100 Subject: [PATCH 04/18] :white_check_mark: [#4606] Add test for document type validation --- .../contrib/zgw_apis/tests/test_validators.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_validators.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_validators.py index c4c5e92795..8c26365583 100644 --- a/src/openforms/registrations/contrib/zgw_apis/tests/test_validators.py +++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_validators.py @@ -551,3 +551,38 @@ def test_validation_objecttype_api_root_must_match_objecttypes_service_api_root( self.assertIn("objecttype", serializer.errors) err = serializer.errors["objecttype"][0] self.assertEqual(err.code, "invalid") + + def test_validate_document_type_exists_when_description_is_provided(self): + base = { + "zgw_api_group": self.zgw_group.pk, + "catalogue": { + "domain": "TEST", + "rsin": "000000000", + }, + "case_type_identification": "ZT-001", + } + + with self.subTest("document type exists"): + data = { + **base, + "document_type_description": "Attachment Informatieobjecttype", + } + serializer = ZaakOptionsSerializer(data=data) + + is_valid = serializer.is_valid() + + self.assertTrue(is_valid) + + with self.subTest("document type exists, not related to case type"): + data = { + **base, + "document_type_description": "PDF Informatieobjecttype", + } + serializer = ZaakOptionsSerializer(data=data) + + is_valid = serializer.is_valid() + + self.assertFalse(is_valid) + self.assertIn("document_type_description", serializer.errors) + err = serializer.errors["document_type_description"][0] + self.assertEqual(err.code, "not-found") From 6c2f1a1cdbff583ba658ceb99251b1fef8863083 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Mon, 11 Nov 2024 17:53:24 +0100 Subject: [PATCH 05/18] :safety_vest: [#4606] Validate document type reference --- .../registrations/contrib/zgw_apis/options.py | 42 ++- ...e_exists_when_description_is_provided.yaml | 256 ++++++++++++++++++ 2 files changed, 293 insertions(+), 5 deletions(-) create mode 100644 src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/OptionsSerializerTests/OptionsSerializerTests.test_validate_document_type_exists_when_description_is_provided.yaml diff --git a/src/openforms/registrations/contrib/zgw_apis/options.py b/src/openforms/registrations/contrib/zgw_apis/options.py index e5ab376a40..9562ac2560 100644 --- a/src/openforms/registrations/contrib/zgw_apis/options.py +++ b/src/openforms/registrations/contrib/zgw_apis/options.py @@ -102,8 +102,9 @@ class ZaakOptionsSerializer(JsonSchemaSerializerMixin, serializers.Serializer): default="", ) informatieobjecttype = serializers.URLField( - required=True, + required=False, help_text=_("URL of the INFORMATIEOBJECTTYPE in the Catalogi API"), + default="", ) organisatie_rsin = serializers.CharField( required=False, @@ -223,6 +224,17 @@ def validate(self, attrs: RegistrationOptions) -> RegistrationOptions: code="required", ) + # Legacy forms will have informatieobjecttype set, new forms can set + # document_type_description. Both may be set - in that case, `document_type_description` + # is preferred. + if not attrs["document_type_description"] and not attrs["informatieobjecttype"]: + raise serializers.ValidationError( + { + "document_type_description": _("You must specify a document type"), + }, + code="required", + ) + validate_business_logic = self.context.get("validate_business_logic", True) if not validate_business_logic: return attrs @@ -359,6 +371,7 @@ def _validate_catalogue_case_and_doc_type( catalogue_option = attrs.get("catalogue") case_type_identification = attrs["case_type_identification"] + document_type_description = attrs["document_type_description"] # legacy case_type_url = attrs["zaaktype"] @@ -382,8 +395,8 @@ def _validate_catalogue_case_and_doc_type( ) err_invalid_document_type = ErrorDetail( _( - "The provided informatieobjecttype does not exist in the specified " - "selected case type or Catalogi API." + "The provided informatieobjecttype does not exist in the selected case " + "type or Catalogi API." ), # type: ignore code="not-found", ) @@ -437,8 +450,27 @@ def _validate_catalogue_case_and_doc_type( elif case_type_url not in catalogus["zaaktypen"]: _errors["zaaktype"] = err_invalid_case_type - # Validate document type reference - if document_type_url not in valid_document_type_urls: + # validate the document type reference. Note that the validation does not + # consider versions - as soon as the document type was present with any version + # of the case type at any point, it is allowed to go through. This *may* lead + # to runtime errors if the document type (or its version) is no longer related + # to the case type version that applies to the moment of registration. + if document_type_description: + document_type_versions = client.find_informatieobjecttypen( + catalogus=catalogus["url"], + description=document_type_description, + ) + if document_type_versions is None: + _errors["document_type_description"] = err_invalid_document_type + else: + document_type_urls = {item["url"] for item in document_type_versions} + # check the intersection with the known good URLs + intersection = document_type_urls & set(valid_document_type_urls) + if not intersection: + _errors["document_type_description"] = err_invalid_document_type + + # Validate document type URL reference against possible valid URLs. + elif document_type_url not in valid_document_type_urls: _errors["informatieobjecttype"] = err_invalid_document_type else: diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/OptionsSerializerTests/OptionsSerializerTests.test_validate_document_type_exists_when_description_is_provided.yaml b/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/OptionsSerializerTests/OptionsSerializerTests.test_validate_document_type_exists_when_description_is_provided.yaml new file mode 100644 index 0000000000..0ca0652891 --- /dev/null +++ b/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/OptionsSerializerTests/OptionsSerializerTests.test_validate_document_type_exists_when_description_is_provided.yaml @@ -0,0 +1,256 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTM0NDgxNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.tAD3fE09ApDWQoGqdBBTdf8PvzqEn8PzYc9WZkL4Q5Q + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/catalogussen?domein=TEST&rsin=000000000 + response: + body: + string: '{"count":1,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","domein":"TEST","rsin":"000000000","contactpersoonBeheerNaam":"Test + name","contactpersoonBeheerTelefoonnummer":"","contactpersoonBeheerEmailadres":"","zaaktypen":["http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400","http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc"],"besluittypen":[],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/7a474713-0833-402a-8441-e467c08ac55b","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/b2d83b94-9b9b-4e80-a82f-73ff993c62f3","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/29b63e5c-3835-4f68-8fad-f2aea9ae6b71"],"naam":"Test + catalog","versie":"","begindatumVersie":null}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '985' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTM0NDgxNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.tAD3fE09ApDWQoGqdBBTdf8PvzqEn8PzYc9WZkL4Q5Q + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/zaaktypen?catalogus=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fcatalogussen%2Fbd58635c-793e-446d-a7e0-460d7b04829d&identificatie=ZT-001 + response: + body: + string: '{"count":2,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400","identificatie":"ZT-001","omschrijving":"Test","omschrijvingGeneriek":"","vertrouwelijkheidaanduiding":"intern","doel":"testen","aanleiding":"integratietests","toelichting":"","indicatieInternOfExtern":"intern","handelingInitiator":"Formulier + indienen","onderwerp":"Testformulier","handelingBehandelaar":"Controleren","doorlooptijd":"P1D","servicenorm":null,"opschortingEnAanhoudingMogelijk":false,"verlengingMogelijk":false,"verlengingstermijn":null,"trefwoorden":[],"publicatieIndicatie":false,"publicatietekst":"","verantwoordingsrelatie":[],"productenOfDiensten":[],"selectielijstProcestype":"https://selectielijst.openzaak.nl/api/v1/procestypen/aa8aa2fd-b9c6-4e34-9a6c-58a677f60ea0","referentieproces":{"naam":"Testen","link":""},"concept":false,"verantwoordelijke":"Ontwikkelaar","beginGeldigheid":"2023-01-01","eindeGeldigheid":"2024-03-26","versiedatum":"2023-01-01","beginObject":"2023-01-01","eindeObject":null,"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","statustypen":["http://localhost:8003/catalogi/api/v1/statustypen/d1ce96ef-325d-4e2f-a325-d7ed017f3b81","http://localhost:8003/catalogi/api/v1/statustypen/658becc5-fab6-43ad-8289-2beff5c65945"],"resultaattypen":["http://localhost:8003/catalogi/api/v1/resultaattypen/ec03d4e6-c010-4163-9c05-8247def5f45c"],"eigenschappen":["http://localhost:8003/catalogi/api/v1/eigenschappen/7eada907-ffb7-4846-9494-68eb1452182c"],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"],"roltypen":["http://localhost:8003/catalogi/api/v1/roltypen/0333eec0-6240-4f90-adf9-8f98edcd5563","http://localhost:8003/catalogi/api/v1/roltypen/cebf7a53-297d-4308-869a-4385cfc42549"],"besluittypen":[],"deelzaaktypen":[],"gerelateerdeZaaktypen":[],"zaakobjecttypen":[]},{"url":"http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","identificatie":"ZT-001","omschrijving":"Test","omschrijvingGeneriek":"","vertrouwelijkheidaanduiding":"intern","doel":"testen","aanleiding":"integratietests","toelichting":"","indicatieInternOfExtern":"intern","handelingInitiator":"Formulier + indienen","onderwerp":"Testformulier","handelingBehandelaar":"Controleren","doorlooptijd":"P1D","servicenorm":null,"opschortingEnAanhoudingMogelijk":false,"verlengingMogelijk":false,"verlengingstermijn":null,"trefwoorden":[],"publicatieIndicatie":false,"publicatietekst":"","verantwoordingsrelatie":[],"productenOfDiensten":[],"selectielijstProcestype":"https://selectielijst.openzaak.nl/api/v1/procestypen/aa8aa2fd-b9c6-4e34-9a6c-58a677f60ea0","referentieproces":{"naam":"Testen","link":""},"concept":false,"verantwoordelijke":"Ontwikkelaar","beginGeldigheid":"2024-03-26","eindeGeldigheid":null,"versiedatum":"2024-03-26","beginObject":"2023-01-01","eindeObject":null,"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","statustypen":["http://localhost:8003/catalogi/api/v1/statustypen/1de05b57-a938-47e4-b808-f129c6406b60","http://localhost:8003/catalogi/api/v1/statustypen/6443ac1a-04a1-4335-9db2-5f3c998dbb34"],"resultaattypen":["http://localhost:8003/catalogi/api/v1/resultaattypen/65b7cedd-5729-41bd-b9c7-1f51d7583340"],"eigenschappen":["http://localhost:8003/catalogi/api/v1/eigenschappen/b659caed-e39e-47e3-ac51-bc8bd2ad797e"],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"],"roltypen":["http://localhost:8003/catalogi/api/v1/roltypen/43e8026c-8abd-4b29-8a4c-ac2a37bc6f5b","http://localhost:8003/catalogi/api/v1/roltypen/7f1887e8-bf22-47e7-ae52-ed6848d7e70e"],"besluittypen":[],"deelzaaktypen":[],"gerelateerdeZaaktypen":[],"zaakobjecttypen":[]}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '3897' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTM0NDgxNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.tAD3fE09ApDWQoGqdBBTdf8PvzqEn8PzYc9WZkL4Q5Q + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/informatieobjecttypen?catalogus=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fcatalogussen%2Fbd58635c-793e-446d-a7e0-460d7b04829d&omschrijving=Attachment+Informatieobjecttype + response: + body: + string: '{"count":1,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","omschrijving":"Attachment + Informatieobjecttype","vertrouwelijkheidaanduiding":"openbaar","beginGeldigheid":"2024-03-19","eindeGeldigheid":"2024-07-10","concept":false,"besluittypen":[],"informatieobjectcategorie":"Test + category","trefwoord":[],"omschrijvingGeneriek":{"informatieobjecttypeOmschrijvingGeneriek":"","definitieInformatieobjecttypeOmschrijvingGeneriek":"","herkomstInformatieobjecttypeOmschrijvingGeneriek":"","hierarchieInformatieobjecttypeOmschrijvingGeneriek":"","opmerkingInformatieobjecttypeOmschrijvingGeneriek":""},"zaaktypen":["http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400"],"beginObject":"2024-03-19","eindeObject":"2024-07-10"}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '1038' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTM0NDgxNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.tAD3fE09ApDWQoGqdBBTdf8PvzqEn8PzYc9WZkL4Q5Q + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/catalogussen?domein=TEST&rsin=000000000 + response: + body: + string: '{"count":1,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","domein":"TEST","rsin":"000000000","contactpersoonBeheerNaam":"Test + name","contactpersoonBeheerTelefoonnummer":"","contactpersoonBeheerEmailadres":"","zaaktypen":["http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400","http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc"],"besluittypen":[],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/7a474713-0833-402a-8441-e467c08ac55b","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/b2d83b94-9b9b-4e80-a82f-73ff993c62f3","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/29b63e5c-3835-4f68-8fad-f2aea9ae6b71"],"naam":"Test + catalog","versie":"","begindatumVersie":null}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '985' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTM0NDgxNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.tAD3fE09ApDWQoGqdBBTdf8PvzqEn8PzYc9WZkL4Q5Q + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/zaaktypen?catalogus=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fcatalogussen%2Fbd58635c-793e-446d-a7e0-460d7b04829d&identificatie=ZT-001 + response: + body: + string: '{"count":2,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400","identificatie":"ZT-001","omschrijving":"Test","omschrijvingGeneriek":"","vertrouwelijkheidaanduiding":"intern","doel":"testen","aanleiding":"integratietests","toelichting":"","indicatieInternOfExtern":"intern","handelingInitiator":"Formulier + indienen","onderwerp":"Testformulier","handelingBehandelaar":"Controleren","doorlooptijd":"P1D","servicenorm":null,"opschortingEnAanhoudingMogelijk":false,"verlengingMogelijk":false,"verlengingstermijn":null,"trefwoorden":[],"publicatieIndicatie":false,"publicatietekst":"","verantwoordingsrelatie":[],"productenOfDiensten":[],"selectielijstProcestype":"https://selectielijst.openzaak.nl/api/v1/procestypen/aa8aa2fd-b9c6-4e34-9a6c-58a677f60ea0","referentieproces":{"naam":"Testen","link":""},"concept":false,"verantwoordelijke":"Ontwikkelaar","beginGeldigheid":"2023-01-01","eindeGeldigheid":"2024-03-26","versiedatum":"2023-01-01","beginObject":"2023-01-01","eindeObject":null,"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","statustypen":["http://localhost:8003/catalogi/api/v1/statustypen/d1ce96ef-325d-4e2f-a325-d7ed017f3b81","http://localhost:8003/catalogi/api/v1/statustypen/658becc5-fab6-43ad-8289-2beff5c65945"],"resultaattypen":["http://localhost:8003/catalogi/api/v1/resultaattypen/ec03d4e6-c010-4163-9c05-8247def5f45c"],"eigenschappen":["http://localhost:8003/catalogi/api/v1/eigenschappen/7eada907-ffb7-4846-9494-68eb1452182c"],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"],"roltypen":["http://localhost:8003/catalogi/api/v1/roltypen/0333eec0-6240-4f90-adf9-8f98edcd5563","http://localhost:8003/catalogi/api/v1/roltypen/cebf7a53-297d-4308-869a-4385cfc42549"],"besluittypen":[],"deelzaaktypen":[],"gerelateerdeZaaktypen":[],"zaakobjecttypen":[]},{"url":"http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","identificatie":"ZT-001","omschrijving":"Test","omschrijvingGeneriek":"","vertrouwelijkheidaanduiding":"intern","doel":"testen","aanleiding":"integratietests","toelichting":"","indicatieInternOfExtern":"intern","handelingInitiator":"Formulier + indienen","onderwerp":"Testformulier","handelingBehandelaar":"Controleren","doorlooptijd":"P1D","servicenorm":null,"opschortingEnAanhoudingMogelijk":false,"verlengingMogelijk":false,"verlengingstermijn":null,"trefwoorden":[],"publicatieIndicatie":false,"publicatietekst":"","verantwoordingsrelatie":[],"productenOfDiensten":[],"selectielijstProcestype":"https://selectielijst.openzaak.nl/api/v1/procestypen/aa8aa2fd-b9c6-4e34-9a6c-58a677f60ea0","referentieproces":{"naam":"Testen","link":""},"concept":false,"verantwoordelijke":"Ontwikkelaar","beginGeldigheid":"2024-03-26","eindeGeldigheid":null,"versiedatum":"2024-03-26","beginObject":"2023-01-01","eindeObject":null,"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","statustypen":["http://localhost:8003/catalogi/api/v1/statustypen/1de05b57-a938-47e4-b808-f129c6406b60","http://localhost:8003/catalogi/api/v1/statustypen/6443ac1a-04a1-4335-9db2-5f3c998dbb34"],"resultaattypen":["http://localhost:8003/catalogi/api/v1/resultaattypen/65b7cedd-5729-41bd-b9c7-1f51d7583340"],"eigenschappen":["http://localhost:8003/catalogi/api/v1/eigenschappen/b659caed-e39e-47e3-ac51-bc8bd2ad797e"],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"],"roltypen":["http://localhost:8003/catalogi/api/v1/roltypen/43e8026c-8abd-4b29-8a4c-ac2a37bc6f5b","http://localhost:8003/catalogi/api/v1/roltypen/7f1887e8-bf22-47e7-ae52-ed6848d7e70e"],"besluittypen":[],"deelzaaktypen":[],"gerelateerdeZaaktypen":[],"zaakobjecttypen":[]}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '3897' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTM0NDgxNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.tAD3fE09ApDWQoGqdBBTdf8PvzqEn8PzYc9WZkL4Q5Q + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/informatieobjecttypen?catalogus=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fcatalogussen%2Fbd58635c-793e-446d-a7e0-460d7b04829d&omschrijving=PDF+Informatieobjecttype + response: + body: + string: '{"count":2,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/29b63e5c-3835-4f68-8fad-f2aea9ae6b71","catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","omschrijving":"PDF + Informatieobjecttype","vertrouwelijkheidaanduiding":"openbaar","beginGeldigheid":"2024-07-11","eindeGeldigheid":null,"concept":false,"besluittypen":[],"informatieobjectcategorie":"Test + category","trefwoord":[],"omschrijvingGeneriek":{"informatieobjecttypeOmschrijvingGeneriek":"","definitieInformatieobjecttypeOmschrijvingGeneriek":"","herkomstInformatieobjecttypeOmschrijvingGeneriek":"","hierarchieInformatieobjecttypeOmschrijvingGeneriek":"","opmerkingInformatieobjecttypeOmschrijvingGeneriek":""},"zaaktypen":[],"beginObject":"2024-03-19","eindeObject":null},{"url":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/7a474713-0833-402a-8441-e467c08ac55b","catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","omschrijving":"PDF + Informatieobjecttype","vertrouwelijkheidaanduiding":"openbaar","beginGeldigheid":"2024-03-19","eindeGeldigheid":"2024-07-10","concept":false,"besluittypen":[],"informatieobjectcategorie":"Test + category","trefwoord":[],"omschrijvingGeneriek":{"informatieobjecttypeOmschrijvingGeneriek":"","definitieInformatieobjecttypeOmschrijvingGeneriek":"","herkomstInformatieobjecttypeOmschrijvingGeneriek":"","hierarchieInformatieobjecttypeOmschrijvingGeneriek":"","opmerkingInformatieobjecttypeOmschrijvingGeneriek":""},"zaaktypen":[],"beginObject":"2024-03-19","eindeObject":null}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '1641' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +version: 1 From 1cdad20544919143023e079af3f2ba6b8a181d23 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Tue, 12 Nov 2024 08:35:53 +0100 Subject: [PATCH 06/18] :boom: [#4606] Rename serializer and fields to English The serializer that produces the available document types is now properly in English, to be consistent with the rest of the serializers. This requires an update to the formio-builder too. --- src/openapi.yaml | 52 +++++++++---------- .../contrib/objects_api/api/filters.py | 4 +- src/openforms/contrib/objects_api/api/urls.py | 4 +- .../contrib/objects_api/api/views.py | 10 ++-- src/openforms/contrib/zgw/api/serializers.py | 39 +++++++------- src/openforms/contrib/zgw/api/views.py | 12 ++--- .../objectsapi/fields/DocumentTypes.js | 8 +-- .../registrations/objectsapi/mocks.js | 32 ++++++------ src/openforms/js/components/form/file.js | 4 +- .../contrib/zgw_apis/api/filters.py | 4 +- .../contrib/zgw_apis/api/urls.py | 6 +-- .../contrib/zgw_apis/api/views.py | 28 +++++----- 12 files changed, 99 insertions(+), 104 deletions(-) diff --git a/src/openapi.yaml b/src/openapi.yaml index c4138f76be..495b782690 100644 --- a/src/openapi.yaml +++ b/src/openapi.yaml @@ -3529,7 +3529,7 @@ paths: schema: type: array items: - $ref: '#/components/schemas/InformatieObjectType' + $ref: '#/components/schemas/DocumentType' description: '' headers: X-Session-Expires-In: @@ -4224,7 +4224,7 @@ paths: schema: type: array items: - $ref: '#/components/schemas/InformatieObjectType' + $ref: '#/components/schemas/DocumentType' description: '' headers: X-Session-Expires-In: @@ -7564,6 +7564,29 @@ components: - form type: string description: '* `form` - form' + DocumentType: + type: object + properties: + description: + type: string + description: The description uniquely identifies a document type within + a catalogue. Multiple versions of the same document type may exist, these + have non-overlapping valid from/valid until dates. + isPublished: + type: boolean + description: Unpublished document types may be returned when the feature + flag 'ZGW_APIS_INCLUDE_DRAFTS' is enabled. + url: + type: string + format: uri + catalogueLabel: + type: string + description: A representation of the catalogue containing the document type. + required: + - catalogueLabel + - description + - isPublished + - url EmailVerification: type: object properties: @@ -8732,31 +8755,6 @@ components: description: |- * `delete_permanently` - Submissions will be deleted * `make_anonymous` - Sensitive data within the submissions will be deleted - InformatieObjectType: - type: object - properties: - url: - type: string - format: uri - omschrijving: - type: string - title: description - description: The description uniquely identifies a document type within - a catalogue. Multiple versions of the same document type may exist, these - have non-overlapping valid from/valid until dates. - catalogusLabel: - type: string - title: catalogue label - description: A representation of the catalogue containing the document type. - isPublished: - type: boolean - description: Unpublished document types may be returned when the feature - flag 'ZGW_APIS_INCLUDE_DRAFTS' is enabled. - required: - - catalogusLabel - - isPublished - - omschrijving - - url Language: type: object properties: diff --git a/src/openforms/contrib/objects_api/api/filters.py b/src/openforms/contrib/objects_api/api/filters.py index 9c576308ed..db8bc0fd66 100644 --- a/src/openforms/contrib/objects_api/api/filters.py +++ b/src/openforms/contrib/objects_api/api/filters.py @@ -38,7 +38,5 @@ class APIGroupQueryParamsSerializer( pass -class ListInformatieObjectTypenQueryParamsSerializer( - ObjectsAPIGroupMixin, DocumentTypesFilter -): +class ListDocumentTypesQueryParamsSerializer(ObjectsAPIGroupMixin, DocumentTypesFilter): pass diff --git a/src/openforms/contrib/objects_api/api/urls.py b/src/openforms/contrib/objects_api/api/urls.py index c57da5a15c..0aa154ac73 100644 --- a/src/openforms/contrib/objects_api/api/urls.py +++ b/src/openforms/contrib/objects_api/api/urls.py @@ -2,7 +2,7 @@ from .views import ( CatalogueListView, - InformatieObjectTypenListView, + DocumentTypesListView, ObjecttypesListView, ObjecttypeVersionsListView, ) @@ -27,7 +27,7 @@ ), path( "informatieobjecttypen", - InformatieObjectTypenListView.as_view(), + DocumentTypesListView.as_view(), name="iotypen-list", ), ] diff --git a/src/openforms/contrib/objects_api/api/views.py b/src/openforms/contrib/objects_api/api/views.py index 1944166956..75bd5a7e25 100644 --- a/src/openforms/contrib/objects_api/api/views.py +++ b/src/openforms/contrib/objects_api/api/views.py @@ -9,13 +9,13 @@ from openforms.api.views import ListMixin from openforms.contrib.zgw.api.views import ( BaseCatalogueListView, - BaseInformatieObjectTypenListView, + BaseDocumentTypesListView, ) from ..clients import get_objecttypes_client from .filters import ( APIGroupQueryParamsSerializer, - ListInformatieObjectTypenQueryParamsSerializer, + ListDocumentTypesQueryParamsSerializer, ) from .serializers import ( ObjectsAPIGroupInputSerializer, @@ -103,8 +103,8 @@ class CatalogueListView(BaseCatalogueListView): "List the available InformatieObjectTypen from the provided Objects API group" ), tags=["contrib"], - parameters=[ListInformatieObjectTypenQueryParamsSerializer], + parameters=[ListDocumentTypesQueryParamsSerializer], ), ) -class InformatieObjectTypenListView(BaseInformatieObjectTypenListView): - filter_serializer_class = ListInformatieObjectTypenQueryParamsSerializer +class DocumentTypesListView(BaseDocumentTypesListView): + filter_serializer_class = ListDocumentTypesQueryParamsSerializer diff --git a/src/openforms/contrib/zgw/api/serializers.py b/src/openforms/contrib/zgw/api/serializers.py index ab37e76883..79ed39bbe9 100644 --- a/src/openforms/contrib/zgw/api/serializers.py +++ b/src/openforms/contrib/zgw/api/serializers.py @@ -56,22 +56,8 @@ class CaseTypeSerializer(serializers.Serializer): ) -class CaseTypeProductSerializer(serializers.Serializer): - url = serializers.CharField( - label=_("url"), - help_text=_("The url of a product bound to a case type. "), - ) +class DocumentTypeSerializer(serializers.Serializer): description = serializers.CharField( - label=_("description"), - help_text=_("The description of a product bound to a case type. "), - required=False, - ) - - -# TODO: OF 3.0 -> use English instead of Dutch. -class InformatieObjectTypeSerializer(serializers.Serializer): - url = serializers.URLField(label=_("url")) - omschrijving = serializers.CharField( label=_("description"), help_text=_( "The description uniquely identifies a document type within a catalogue. " @@ -79,10 +65,6 @@ class InformatieObjectTypeSerializer(serializers.Serializer): "non-overlapping valid from/valid until dates." ), ) - catalogus_label = serializers.CharField( - label=_("catalogue label"), - help_text=_("A representation of the catalogue containing the document type."), - ) is_published = serializers.BooleanField( label=_("Is published"), help_text=_( @@ -90,3 +72,22 @@ class InformatieObjectTypeSerializer(serializers.Serializer): "'ZGW_APIS_INCLUDE_DRAFTS' is enabled." ), ) + # DeprecationWarning - only relevant for Formio registration attributes + url = serializers.URLField(label=_("url")) + # DeprecationWarning - only relevant for Formio registration attributes + catalogue_label = serializers.CharField( + label=_("catalogue label"), + help_text=_("A representation of the catalogue containing the document type."), + ) + + +class CaseTypeProductSerializer(serializers.Serializer): + url = serializers.CharField( + label=_("url"), + help_text=_("The url of a product bound to a case type. "), + ) + description = serializers.CharField( + label=_("description"), + help_text=_("The description of a product bound to a case type. "), + required=False, + ) diff --git a/src/openforms/contrib/zgw/api/views.py b/src/openforms/contrib/zgw/api/views.py index 51b5f099fd..7443d870ff 100644 --- a/src/openforms/contrib/zgw/api/views.py +++ b/src/openforms/contrib/zgw/api/views.py @@ -7,7 +7,7 @@ from openforms.api.views import ListMixin from .filters import DocumentTypesFilter, ProvidesCatalogiClientQueryParamsSerializer -from .serializers import CatalogueSerializer, InformatieObjectTypeSerializer +from .serializers import CatalogueSerializer, DocumentTypeSerializer @dataclass @@ -54,17 +54,17 @@ def get_objects(self): @dataclass class DocumentType: catalogue: Catalogue - omschrijving: str + description: str url: str = field(compare=False) # different versions have different URLs is_published: bool = field( compare=False ) # different versions may have different publication states - def catalogus_label(self) -> str: + def catalogue_label(self) -> str: return self.catalogue.label -class BaseInformatieObjectTypenListView(ListMixin[DocumentType], APIView): +class BaseDocumentTypesListView(ListMixin[DocumentType], APIView): """ List the available InformatieObjectTypen. @@ -75,7 +75,7 @@ class BaseInformatieObjectTypenListView(ListMixin[DocumentType], APIView): authentication_classes = (authentication.SessionAuthentication,) permission_classes = (permissions.IsAdminUser,) - serializer_class = InformatieObjectTypeSerializer + serializer_class = DocumentTypeSerializer filter_serializer_class: ClassVar[type[DocumentTypesFilter]] def get_objects(self) -> list[DocumentType]: @@ -110,7 +110,7 @@ def get_objects(self) -> list[DocumentType]: for iotype in client.get_all_informatieobjecttypen(catalogus=catalogus_url): document_type = DocumentType( url=iotype["url"], - omschrijving=iotype["omschrijving"], + description=iotype["omschrijving"], catalogue=catalogues[iotype["catalogus"]], is_published=not iotype.get("concept", False), ) diff --git a/src/openforms/js/components/admin/form_design/registrations/objectsapi/fields/DocumentTypes.js b/src/openforms/js/components/admin/form_design/registrations/objectsapi/fields/DocumentTypes.js index 4b955256f2..f00a186f09 100644 --- a/src/openforms/js/components/admin/form_design/registrations/objectsapi/fields/DocumentTypes.js +++ b/src/openforms/js/components/admin/form_design/registrations/objectsapi/fields/DocumentTypes.js @@ -40,10 +40,10 @@ const getDocumentTypes = async (apiGroupID, catalogueUrl) => { if (!response.ok) { throw new Error('Loading available document types failed'); } - const documentTypes = response.data.sort((a, b) => a.omschrijving.localeCompare(b.omschrijving)); - return documentTypes.map(({omschrijving, isPublished}) => ({ - value: omschrijving, - label: omschrijving, + const documentTypes = response.data.sort((a, b) => a.description.localeCompare(b.description)); + return documentTypes.map(({description, isPublished}) => ({ + value: description, + label: description, isPublished: isPublished, })); }; diff --git a/src/openforms/js/components/admin/form_design/registrations/objectsapi/mocks.js b/src/openforms/js/components/admin/form_design/registrations/objectsapi/mocks.js index 7017da2b99..9820d4650b 100644 --- a/src/openforms/js/components/admin/form_design/registrations/objectsapi/mocks.js +++ b/src/openforms/js/components/admin/form_design/registrations/objectsapi/mocks.js @@ -59,54 +59,54 @@ const DOCUMENT_TYPES = { 'https://example.com/catalogi/api/v1/catalogussen/1': [ { url: 'https://example.com/catalogi/api/v1/iot/1', - omschrijving: 'Test PDF', - catalogusLabel: 'Catalogus 1', + description: 'Test PDF', + catalogueLabel: 'Catalogus 1', isPublished: true, }, { url: 'https://example.com/catalogi/api/v1/iot/2', - omschrijving: 'Test attachment', - catalogusLabel: 'Catalogus 1', + description: 'Test attachment', + catalogueLabel: 'Catalogus 1', isPublished: true, }, ], 'https://example.com/catalogi/api/v1/catalogussen/2': [ { url: 'https://example.com/catalogi/api/v1/iot/1', - omschrijving: 'Other PDF', - catalogusLabel: 'Catalogus 2', + description: 'Other PDF', + catalogueLabel: 'Catalogus 2', isPublished: true, }, { url: 'https://example.com/catalogi/api/v1/iot/4', - omschrijving: 'Other attachment', - catalogusLabel: 'Catalogus 2', + description: 'Other attachment', + catalogueLabel: 'Catalogus 2', isPublished: true, }, ], 'https://example.com/catalogi/api/v1/catalogussen/3': [ { url: 'https://example.com/catalogi/api/v1/iot/10', - omschrijving: 'Document type 1', - catalogusLabel: 'TEST (111111111)', + description: 'Document type 1', + catalogueLabel: 'TEST (111111111)', isPublished: false, }, { url: 'https://example.com/catalogi/api/v1/iot/11', - omschrijving: 'Document type 2', - catalogusLabel: 'TEST (111111111)', + description: 'Document type 2', + catalogueLabel: 'TEST (111111111)', isPublished: true, }, { url: 'https://example.com/catalogi/api/v1/iot/12', - omschrijving: 'Document type 3', - catalogusLabel: 'TEST (111111111)', + description: 'Document type 3', + catalogueLabel: 'TEST (111111111)', isPublished: true, }, { url: 'https://example.com/catalogi/api/v1/iot/13', - omschrijving: 'Document type 4 with a rather long draft description', - catalogusLabel: 'TEST (111111111)', + description: 'Document type 4 with a rather long draft description', + catalogueLabel: 'TEST (111111111)', isPublished: false, }, ], diff --git a/src/openforms/js/components/form/file.js b/src/openforms/js/components/form/file.js index 4fafdb5162..9ee497b635 100644 --- a/src/openforms/js/components/form/file.js +++ b/src/openforms/js/components/form/file.js @@ -58,9 +58,9 @@ const getSetOfBackends = instance => { * * @return {Promise<{ * backendLabel: string; - * catalogusLabel: string; + * catalogueLabel: string; * url: string; - * omschrijving: string; + * description: string; * }>[]} * An array of available documenttypes with the relevant backend label attached. */ diff --git a/src/openforms/registrations/contrib/zgw_apis/api/filters.py b/src/openforms/registrations/contrib/zgw_apis/api/filters.py index e28905253a..43682c1de5 100644 --- a/src/openforms/registrations/contrib/zgw_apis/api/filters.py +++ b/src/openforms/registrations/contrib/zgw_apis/api/filters.py @@ -34,9 +34,7 @@ class APIGroupQueryParamsSerializer( pass -class ListInformatieObjectTypenQueryParamsSerializer( - ZGWAPIGroupMixin, DocumentTypesFilter -): +class ListDocumentTypesQueryParamsSerializer(ZGWAPIGroupMixin, DocumentTypesFilter): pass diff --git a/src/openforms/registrations/contrib/zgw_apis/api/urls.py b/src/openforms/registrations/contrib/zgw_apis/api/urls.py index aac366672e..657f70a3f5 100644 --- a/src/openforms/registrations/contrib/zgw_apis/api/urls.py +++ b/src/openforms/registrations/contrib/zgw_apis/api/urls.py @@ -3,7 +3,7 @@ from .views import ( CaseTypesListView, CatalogueListView, - InformatieObjectTypenListView, + DocumentTypesListView, ProductsListView, ) @@ -12,10 +12,10 @@ urlpatterns = [ path("catalogues", CatalogueListView.as_view(), name="catalogue-list"), path("case-types", CaseTypesListView.as_view(), name="case-type-list"), - path("products", ProductsListView.as_view(), name="product-list"), path( "informatieobjecttypen", - InformatieObjectTypenListView.as_view(), + DocumentTypesListView.as_view(), name="iotypen-list", ), + path("products", ProductsListView.as_view(), name="product-list"), ] diff --git a/src/openforms/registrations/contrib/zgw_apis/api/views.py b/src/openforms/registrations/contrib/zgw_apis/api/views.py index 089758abc9..5e3101c66e 100644 --- a/src/openforms/registrations/contrib/zgw_apis/api/views.py +++ b/src/openforms/registrations/contrib/zgw_apis/api/views.py @@ -14,7 +14,7 @@ ) from openforms.contrib.zgw.api.views import ( BaseCatalogueListView, - BaseInformatieObjectTypenListView, + BaseDocumentTypesListView, ) from openforms.contrib.zgw.products_and_services import resolve_case_type_products from openforms.utils.date import datetime_in_amsterdam @@ -22,7 +22,7 @@ from .filters import ( APIGroupQueryParamsSerializer, ListCaseTypesQueryParamsSerializer, - ListInformatieObjectTypenQueryParamsSerializer, + ListDocumentTypesQueryParamsSerializer, ListProductsQueryParamsSerializer, ) @@ -80,6 +80,18 @@ def get_objects(self): return case_types +@extend_schema_view( + get=extend_schema( + summary=_( + "List the available InformatieObjectTypen from the provided ZGW API group" + ), + parameters=[ListDocumentTypesQueryParamsSerializer], + ), +) +class DocumentTypesListView(BaseDocumentTypesListView): + filter_serializer_class = ListDocumentTypesQueryParamsSerializer + + @dataclass class Product: url: str @@ -132,15 +144,3 @@ def get_objects(self): ) return products - - -@extend_schema_view( - get=extend_schema( - summary=_( - "List the available InformatieObjectTypen from the provided ZGW API group" - ), - parameters=[ListInformatieObjectTypenQueryParamsSerializer], - ), -) -class InformatieObjectTypenListView(BaseInformatieObjectTypenListView): - filter_serializer_class = ListInformatieObjectTypenQueryParamsSerializer From 32c41e66cc8c732ce8e87b21ecd186de8d0237e7 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Tue, 12 Nov 2024 08:45:29 +0100 Subject: [PATCH 07/18] :boom: [#4606] Normalize API endpoints Replaced endpoints with their English variant for consistency. --- src/openapi.yaml | 8 ++++---- src/openforms/contrib/objects_api/api/urls.py | 2 +- .../registrations/objectsapi/fields/DocumentTypes.js | 2 +- .../admin/form_design/registrations/objectsapi/mocks.js | 2 +- src/openforms/js/components/form/file.js | 4 ++-- src/openforms/registrations/contrib/zgw_apis/api/urls.py | 6 +----- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/openapi.yaml b/src/openapi.yaml index 495b782690..359bc4ace5 100644 --- a/src/openapi.yaml +++ b/src/openapi.yaml @@ -3491,9 +3491,9 @@ paths: $ref: '#/components/headers/X-Is-Form-Designer' Content-Language: $ref: '#/components/headers/Content-Language' - /api/v2/objects-api/informatieobjecttypen: + /api/v2/objects-api/document-types: get: - operationId: objects_api_informatieobjecttypen_list + operationId: objects_api_document_types_list description: |- List the available InformatieObjectTypen. @@ -4186,9 +4186,9 @@ paths: $ref: '#/components/headers/X-Is-Form-Designer' Content-Language: $ref: '#/components/headers/Content-Language' - /api/v2/registration/plugins/zgw-api/informatieobjecttypen: + /api/v2/registration/plugins/zgw-api/document-types: get: - operationId: registration_plugins_zgw_api_informatieobjecttypen_list + operationId: registration_plugins_zgw_api_document_types_list description: |- List the available InformatieObjectTypen. diff --git a/src/openforms/contrib/objects_api/api/urls.py b/src/openforms/contrib/objects_api/api/urls.py index 0aa154ac73..b5941e846a 100644 --- a/src/openforms/contrib/objects_api/api/urls.py +++ b/src/openforms/contrib/objects_api/api/urls.py @@ -26,7 +26,7 @@ name="catalogue-list", ), path( - "informatieobjecttypen", + "document-types", DocumentTypesListView.as_view(), name="iotypen-list", ), diff --git a/src/openforms/js/components/admin/form_design/registrations/objectsapi/fields/DocumentTypes.js b/src/openforms/js/components/admin/form_design/registrations/objectsapi/fields/DocumentTypes.js index f00a186f09..76e180fad2 100644 --- a/src/openforms/js/components/admin/form_design/registrations/objectsapi/fields/DocumentTypes.js +++ b/src/openforms/js/components/admin/form_design/registrations/objectsapi/fields/DocumentTypes.js @@ -22,7 +22,7 @@ import {get} from 'utils/fetch'; // Data fetching const CATALOGUES_ENDPOINT = '/api/v2/objects-api/catalogues'; -const IOT_ENDPOINT = '/api/v2/objects-api/informatieobjecttypen'; +const IOT_ENDPOINT = '/api/v2/objects-api/document-types'; const getCatalogues = async apiGroupID => { const response = await get(CATALOGUES_ENDPOINT, {objects_api_group: apiGroupID}); diff --git a/src/openforms/js/components/admin/form_design/registrations/objectsapi/mocks.js b/src/openforms/js/components/admin/form_design/registrations/objectsapi/mocks.js index 9820d4650b..8e7314186c 100644 --- a/src/openforms/js/components/admin/form_design/registrations/objectsapi/mocks.js +++ b/src/openforms/js/components/admin/form_design/registrations/objectsapi/mocks.js @@ -113,7 +113,7 @@ const DOCUMENT_TYPES = { }; export const mockDocumentTypesGet = () => - rest.get(`${API_BASE_URL}/api/v2/objects-api/informatieobjecttypen`, (req, res, ctx) => { + rest.get(`${API_BASE_URL}/api/v2/objects-api/document-types`, (req, res, ctx) => { const catalogusUrl = req.url.searchParams.get('catalogus_url'); const match = DOCUMENT_TYPES[catalogusUrl] ?? []; return res(ctx.json(match)); diff --git a/src/openforms/js/components/form/file.js b/src/openforms/js/components/form/file.js index 9ee497b635..629849b987 100644 --- a/src/openforms/js/components/form/file.js +++ b/src/openforms/js/components/form/file.js @@ -18,12 +18,12 @@ const BaseFileField = Formio.Components.components.file; const getInformatieObjectTypen = async (backend, options) => { switch (backend) { case 'zgw-create-zaak': { - return await get('/api/v2/registration/plugins/zgw-api/informatieobjecttypen', { + return await get('/api/v2/registration/plugins/zgw-api/document-types', { zgw_api_group: options.zgwApiGroup, }); } case 'objects_api': - return await get('/api/v2/objects-api/informatieobjecttypen', { + return await get('/api/v2/objects-api/document-types', { objects_api_group: options.objectsApiGroup, }); default: diff --git a/src/openforms/registrations/contrib/zgw_apis/api/urls.py b/src/openforms/registrations/contrib/zgw_apis/api/urls.py index 657f70a3f5..d4876cb354 100644 --- a/src/openforms/registrations/contrib/zgw_apis/api/urls.py +++ b/src/openforms/registrations/contrib/zgw_apis/api/urls.py @@ -12,10 +12,6 @@ urlpatterns = [ path("catalogues", CatalogueListView.as_view(), name="catalogue-list"), path("case-types", CaseTypesListView.as_view(), name="case-type-list"), - path( - "informatieobjecttypen", - DocumentTypesListView.as_view(), - name="iotypen-list", - ), + path("document-types", DocumentTypesListView.as_view(), name="iotypen-list"), path("products", ProductsListView.as_view(), name="product-list"), ] From e04c3b92c9ce8c7d65c5894765988b61ebb7d026 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Tue, 12 Nov 2024 09:31:54 +0100 Subject: [PATCH 08/18] :sparkles: [#4606] Implement filtering document types down to particular case type --- src/openforms/contrib/zgw/api/filters.py | 24 +++++++++++++++++ src/openforms/contrib/zgw/api/views.py | 33 +++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/openforms/contrib/zgw/api/filters.py b/src/openforms/contrib/zgw/api/filters.py index 99ed7ca12a..7c286f279f 100644 --- a/src/openforms/contrib/zgw/api/filters.py +++ b/src/openforms/contrib/zgw/api/filters.py @@ -12,12 +12,36 @@ def get_ztc_client(self) -> CatalogiClient: class DocumentTypesFilter(serializers.Serializer): + # TODO -> to english catalogus_url = serializers.URLField( label=_("catalogus URL"), help_text=_("Filter informatieobjecttypen against this catalogus URL."), required=False, default="", ) + case_type_identification = serializers.CharField( + required=False, + label=_("case type identification"), + help_text=_( + "Filter document types for a given case type. The identification is unique " + "within the catalogue for a case type. Note that multiple versions of the " + "same case type with the same identification exist. The filter returns a " + "document type if it occurs within any version of the specified case type." + ), + default="", + ) + + def validate(self, attrs): + if attrs["case_type_identification"] and not attrs["catalogus_url"]: + raise serializers.ValidationError( + { + "catalogus_url": _( + "A catalogue URL is required when filtering for a case type." + ), + }, + code="required", + ) + return attrs def get_ztc_client(self) -> CatalogiClient: raise NotImplementedError() diff --git a/src/openforms/contrib/zgw/api/views.py b/src/openforms/contrib/zgw/api/views.py index 7443d870ff..f06434bda9 100644 --- a/src/openforms/contrib/zgw/api/views.py +++ b/src/openforms/contrib/zgw/api/views.py @@ -82,10 +82,39 @@ def get_objects(self) -> list[DocumentType]: filter_serializer = self.filter_serializer_class(data=self.request.query_params) filter_serializer.is_valid(raise_exception=True) - catalogus_url = filter_serializer.validated_data["catalogus_url"] + catalogus_url: str = filter_serializer.validated_data["catalogus_url"] + case_type_identification: str = filter_serializer.validated_data[ + "case_type_identification" + ] document_types: list[DocumentType] = [] with filter_serializer.get_ztc_client() as client: + # if a case type identification filter is provided, filter down the list + # of document types to the ones present in any version of the case type + allowed_urls: set[str] | None + if case_type_identification: + assert catalogus_url + case_type_versions = client.find_case_types( + catalogus=catalogus_url, + identification=case_type_identification, + ) + # no case type version found -> there are definitely no document types + # available + if case_type_versions is None: + return [] + + allowed_urls = set( + sum( + ( + case_type_version.get("informatieobjecttypen", []) + for case_type_version in case_type_versions + ), + [], + ) + ) + else: + allowed_urls = None + # look up the relevant catalogue information, since we need to embed # information in the document types for the formio-builder file component. _catalogues: list[dict] @@ -108,6 +137,8 @@ def get_objects(self) -> list[DocumentType]: # now, look up the document types, possibly filtered for iotype in client.get_all_informatieobjecttypen(catalogus=catalogus_url): + if allowed_urls is not None and iotype["url"] not in allowed_urls: + continue document_type = DocumentType( url=iotype["url"], description=iotype["omschrijving"], From 62cc377435e9ff3b013f637ca2ff449c65257219 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Tue, 12 Nov 2024 09:36:23 +0100 Subject: [PATCH 09/18] :boom: More NL -> EN in API endpoints --- src/openapi.yaml | 28 ++- src/openforms/contrib/zgw/api/filters.py | 11 +- src/openforms/contrib/zgw/api/views.py | 12 +- .../objectsapi/fields/DocumentTypes.js | 2 +- .../registrations/objectsapi/mocks.js | 2 +- .../zgw/fields/DocumentTypeSelect.js | 3 - .../objects_api/tests/test_api_endpoints.py | 4 +- ...eve_filter_by_catalogus_and_case_type.yaml | 176 ++++++++++++++++++ .../zgw_apis/tests/test_api_endpoints.py | 35 +++- 9 files changed, 249 insertions(+), 24 deletions(-) create mode 100644 src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/GetInformatieObjecttypesViewTests/GetInformatieObjecttypesViewTests.test_retrieve_filter_by_catalogus_and_case_type.yaml diff --git a/src/openapi.yaml b/src/openapi.yaml index 359bc4ace5..8a29313a48 100644 --- a/src/openapi.yaml +++ b/src/openapi.yaml @@ -3504,13 +3504,23 @@ paths: API group parameters: - in: query - name: catalogus_url + name: case_type_identification + schema: + type: string + default: '' + minLength: 1 + description: Filter document types for a given case type. The identification + is unique within the catalogue for a case type. Note that multiple versions + of the same case type with the same identification exist. The filter returns + a document type if it occurs within any version of the specified case type. + - in: query + name: catalogue_url schema: type: string format: uri default: '' minLength: 1 - description: Filter informatieobjecttypen against this catalogus URL. + description: Filter informatieobjecttypen against this catalogue URL. - in: query name: objects_api_group schema: @@ -4199,13 +4209,23 @@ paths: group parameters: - in: query - name: catalogus_url + name: case_type_identification + schema: + type: string + default: '' + minLength: 1 + description: Filter document types for a given case type. The identification + is unique within the catalogue for a case type. Note that multiple versions + of the same case type with the same identification exist. The filter returns + a document type if it occurs within any version of the specified case type. + - in: query + name: catalogue_url schema: type: string format: uri default: '' minLength: 1 - description: Filter informatieobjecttypen against this catalogus URL. + description: Filter informatieobjecttypen against this catalogue URL. - in: query name: zgw_api_group schema: diff --git a/src/openforms/contrib/zgw/api/filters.py b/src/openforms/contrib/zgw/api/filters.py index 7c286f279f..bf7fe5cd48 100644 --- a/src/openforms/contrib/zgw/api/filters.py +++ b/src/openforms/contrib/zgw/api/filters.py @@ -12,10 +12,9 @@ def get_ztc_client(self) -> CatalogiClient: class DocumentTypesFilter(serializers.Serializer): - # TODO -> to english - catalogus_url = serializers.URLField( - label=_("catalogus URL"), - help_text=_("Filter informatieobjecttypen against this catalogus URL."), + catalogue_url = serializers.URLField( + label=_("catalogue URL"), + help_text=_("Filter informatieobjecttypen against this catalogue URL."), required=False, default="", ) @@ -32,10 +31,10 @@ class DocumentTypesFilter(serializers.Serializer): ) def validate(self, attrs): - if attrs["case_type_identification"] and not attrs["catalogus_url"]: + if attrs["case_type_identification"] and not attrs["catalogue_url"]: raise serializers.ValidationError( { - "catalogus_url": _( + "catalogue_url": _( "A catalogue URL is required when filtering for a case type." ), }, diff --git a/src/openforms/contrib/zgw/api/views.py b/src/openforms/contrib/zgw/api/views.py index f06434bda9..d4e364c886 100644 --- a/src/openforms/contrib/zgw/api/views.py +++ b/src/openforms/contrib/zgw/api/views.py @@ -82,7 +82,7 @@ def get_objects(self) -> list[DocumentType]: filter_serializer = self.filter_serializer_class(data=self.request.query_params) filter_serializer.is_valid(raise_exception=True) - catalogus_url: str = filter_serializer.validated_data["catalogus_url"] + catalogue_url: str = filter_serializer.validated_data["catalogue_url"] case_type_identification: str = filter_serializer.validated_data[ "case_type_identification" ] @@ -93,9 +93,9 @@ def get_objects(self) -> list[DocumentType]: # of document types to the ones present in any version of the case type allowed_urls: set[str] | None if case_type_identification: - assert catalogus_url + assert catalogue_url case_type_versions = client.find_case_types( - catalogus=catalogus_url, + catalogus=catalogue_url, identification=case_type_identification, ) # no case type version found -> there are definitely no document types @@ -118,8 +118,8 @@ def get_objects(self) -> list[DocumentType]: # look up the relevant catalogue information, since we need to embed # information in the document types for the formio-builder file component. _catalogues: list[dict] - if catalogus_url: - response = client.get(catalogus_url) + if catalogue_url: + response = client.get(catalogue_url) response.raise_for_status() _catalogues = [response.json()] else: @@ -136,7 +136,7 @@ def get_objects(self) -> list[DocumentType]: } # now, look up the document types, possibly filtered - for iotype in client.get_all_informatieobjecttypen(catalogus=catalogus_url): + for iotype in client.get_all_informatieobjecttypen(catalogus=catalogue_url): if allowed_urls is not None and iotype["url"] not in allowed_urls: continue document_type = DocumentType( diff --git a/src/openforms/js/components/admin/form_design/registrations/objectsapi/fields/DocumentTypes.js b/src/openforms/js/components/admin/form_design/registrations/objectsapi/fields/DocumentTypes.js index 76e180fad2..3203b5b9a3 100644 --- a/src/openforms/js/components/admin/form_design/registrations/objectsapi/fields/DocumentTypes.js +++ b/src/openforms/js/components/admin/form_design/registrations/objectsapi/fields/DocumentTypes.js @@ -35,7 +35,7 @@ const getCatalogues = async apiGroupID => { const getDocumentTypes = async (apiGroupID, catalogueUrl) => { const response = await get(IOT_ENDPOINT, { objects_api_group: apiGroupID, - catalogus_url: catalogueUrl, + catalogue_url: catalogueUrl, }); if (!response.ok) { throw new Error('Loading available document types failed'); diff --git a/src/openforms/js/components/admin/form_design/registrations/objectsapi/mocks.js b/src/openforms/js/components/admin/form_design/registrations/objectsapi/mocks.js index 8e7314186c..b1cc496482 100644 --- a/src/openforms/js/components/admin/form_design/registrations/objectsapi/mocks.js +++ b/src/openforms/js/components/admin/form_design/registrations/objectsapi/mocks.js @@ -114,7 +114,7 @@ const DOCUMENT_TYPES = { export const mockDocumentTypesGet = () => rest.get(`${API_BASE_URL}/api/v2/objects-api/document-types`, (req, res, ctx) => { - const catalogusUrl = req.url.searchParams.get('catalogus_url'); + const catalogusUrl = req.url.searchParams.get('catalogue_url'); const match = DOCUMENT_TYPES[catalogusUrl] ?? []; return res(ctx.json(match)); }); diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/fields/DocumentTypeSelect.js b/src/openforms/js/components/admin/form_design/registrations/zgw/fields/DocumentTypeSelect.js index 86e3cb6a02..23d7f4bcc9 100644 --- a/src/openforms/js/components/admin/form_design/registrations/zgw/fields/DocumentTypeSelect.js +++ b/src/openforms/js/components/admin/form_design/registrations/zgw/fields/DocumentTypeSelect.js @@ -11,9 +11,6 @@ import FormRow from 'components/admin/forms/FormRow'; import ReactSelect from 'components/admin/forms/ReactSelect'; import {get} from 'utils/fetch'; -/** - * @todo Implement on the backend - */ const DOCUMENT_TYPES_ENDPOINT = '/api/v2/registration/plugins/zgw-api/document-types'; const getAvailableDocumentTypes = async (apiGroupID, catalogueUrl, caseTypeIdentification) => { diff --git a/src/openforms/registrations/contrib/objects_api/tests/test_api_endpoints.py b/src/openforms/registrations/contrib/objects_api/tests/test_api_endpoints.py index 9fc515bf40..75af39b1fb 100644 --- a/src/openforms/registrations/contrib/objects_api/tests/test_api_endpoints.py +++ b/src/openforms/registrations/contrib/objects_api/tests/test_api_endpoints.py @@ -354,7 +354,7 @@ def test_retrieve_filter_by_catalogus(self): self.endpoint, { "objects_api_group": self.objects_api_group.pk, - "catalogus_url": "http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d", + "catalogue_url": "http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d", }, ) @@ -387,7 +387,7 @@ def test_allow_unpublished_document_types(self): { "objects_api_group": self.objects_api_group.pk, # catalogue in fixture with draft document types - "catalogus_url": "http://localhost:8003/catalogi/api/v1/catalogussen/aa0e0a50-33f6-4473-99a1-b92bab94e749", + "catalogue_url": "http://localhost:8003/catalogi/api/v1/catalogussen/aa0e0a50-33f6-4473-99a1-b92bab94e749", }, ) diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/GetInformatieObjecttypesViewTests/GetInformatieObjecttypesViewTests.test_retrieve_filter_by_catalogus_and_case_type.yaml b/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/GetInformatieObjecttypesViewTests/GetInformatieObjecttypesViewTests.test_retrieve_filter_by_catalogus_and_case_type.yaml new file mode 100644 index 0000000000..8dec9c3c5e --- /dev/null +++ b/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/GetInformatieObjecttypesViewTests/GetInformatieObjecttypesViewTests.test_retrieve_filter_by_catalogus_and_case_type.yaml @@ -0,0 +1,176 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTQwMDc2MiwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.6tZAsoFSeuoqg40CU7wgwPRwzx4GAhdIXmdLVZje7vA + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/catalogussen?domein=VRSN + response: + body: + string: '{"count":0,"next":null,"previous":null,"results":[]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '52' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTQwMDc2MiwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.6tZAsoFSeuoqg40CU7wgwPRwzx4GAhdIXmdLVZje7vA + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/zaaktypen?catalogus=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fcatalogussen%2Fbd58635c-793e-446d-a7e0-460d7b04829d&identificatie=ZT-001 + response: + body: + string: '{"count":2,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400","identificatie":"ZT-001","omschrijving":"Test","omschrijvingGeneriek":"","vertrouwelijkheidaanduiding":"intern","doel":"testen","aanleiding":"integratietests","toelichting":"","indicatieInternOfExtern":"intern","handelingInitiator":"Formulier + indienen","onderwerp":"Testformulier","handelingBehandelaar":"Controleren","doorlooptijd":"P1D","servicenorm":null,"opschortingEnAanhoudingMogelijk":false,"verlengingMogelijk":false,"verlengingstermijn":null,"trefwoorden":[],"publicatieIndicatie":false,"publicatietekst":"","verantwoordingsrelatie":[],"productenOfDiensten":[],"selectielijstProcestype":"https://selectielijst.openzaak.nl/api/v1/procestypen/aa8aa2fd-b9c6-4e34-9a6c-58a677f60ea0","referentieproces":{"naam":"Testen","link":""},"concept":false,"verantwoordelijke":"Ontwikkelaar","beginGeldigheid":"2023-01-01","eindeGeldigheid":"2024-03-26","versiedatum":"2023-01-01","beginObject":"2023-01-01","eindeObject":null,"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","statustypen":["http://localhost:8003/catalogi/api/v1/statustypen/d1ce96ef-325d-4e2f-a325-d7ed017f3b81","http://localhost:8003/catalogi/api/v1/statustypen/658becc5-fab6-43ad-8289-2beff5c65945"],"resultaattypen":["http://localhost:8003/catalogi/api/v1/resultaattypen/ec03d4e6-c010-4163-9c05-8247def5f45c"],"eigenschappen":["http://localhost:8003/catalogi/api/v1/eigenschappen/7eada907-ffb7-4846-9494-68eb1452182c"],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"],"roltypen":["http://localhost:8003/catalogi/api/v1/roltypen/0333eec0-6240-4f90-adf9-8f98edcd5563","http://localhost:8003/catalogi/api/v1/roltypen/cebf7a53-297d-4308-869a-4385cfc42549"],"besluittypen":[],"deelzaaktypen":[],"gerelateerdeZaaktypen":[],"zaakobjecttypen":[]},{"url":"http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","identificatie":"ZT-001","omschrijving":"Test","omschrijvingGeneriek":"","vertrouwelijkheidaanduiding":"intern","doel":"testen","aanleiding":"integratietests","toelichting":"","indicatieInternOfExtern":"intern","handelingInitiator":"Formulier + indienen","onderwerp":"Testformulier","handelingBehandelaar":"Controleren","doorlooptijd":"P1D","servicenorm":null,"opschortingEnAanhoudingMogelijk":false,"verlengingMogelijk":false,"verlengingstermijn":null,"trefwoorden":[],"publicatieIndicatie":false,"publicatietekst":"","verantwoordingsrelatie":[],"productenOfDiensten":[],"selectielijstProcestype":"https://selectielijst.openzaak.nl/api/v1/procestypen/aa8aa2fd-b9c6-4e34-9a6c-58a677f60ea0","referentieproces":{"naam":"Testen","link":""},"concept":false,"verantwoordelijke":"Ontwikkelaar","beginGeldigheid":"2024-03-26","eindeGeldigheid":null,"versiedatum":"2024-03-26","beginObject":"2023-01-01","eindeObject":null,"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","statustypen":["http://localhost:8003/catalogi/api/v1/statustypen/1de05b57-a938-47e4-b808-f129c6406b60","http://localhost:8003/catalogi/api/v1/statustypen/6443ac1a-04a1-4335-9db2-5f3c998dbb34"],"resultaattypen":["http://localhost:8003/catalogi/api/v1/resultaattypen/65b7cedd-5729-41bd-b9c7-1f51d7583340"],"eigenschappen":["http://localhost:8003/catalogi/api/v1/eigenschappen/b659caed-e39e-47e3-ac51-bc8bd2ad797e"],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"],"roltypen":["http://localhost:8003/catalogi/api/v1/roltypen/43e8026c-8abd-4b29-8a4c-ac2a37bc6f5b","http://localhost:8003/catalogi/api/v1/roltypen/7f1887e8-bf22-47e7-ae52-ed6848d7e70e"],"besluittypen":[],"deelzaaktypen":[],"gerelateerdeZaaktypen":[],"zaakobjecttypen":[]}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '3897' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTQwMDc2MiwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.6tZAsoFSeuoqg40CU7wgwPRwzx4GAhdIXmdLVZje7vA + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d + response: + body: + string: '{"url":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","domein":"TEST","rsin":"000000000","contactpersoonBeheerNaam":"Test + name","contactpersoonBeheerTelefoonnummer":"","contactpersoonBeheerEmailadres":"","zaaktypen":["http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400","http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc"],"besluittypen":[],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/7a474713-0833-402a-8441-e467c08ac55b","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/b2d83b94-9b9b-4e80-a82f-73ff993c62f3","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/29b63e5c-3835-4f68-8fad-f2aea9ae6b71"],"naam":"Test + catalog","versie":"","begindatumVersie":null}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, HEAD, OPTIONS + Content-Length: + - '933' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + ETag: + - '"e1d589174bfd280d29dbce6ab0450e18"' + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTQwMDc2MiwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.6tZAsoFSeuoqg40CU7wgwPRwzx4GAhdIXmdLVZje7vA + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/informatieobjecttypen?catalogus=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fcatalogussen%2Fbd58635c-793e-446d-a7e0-460d7b04829d + response: + body: + string: '{"count":4,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/29b63e5c-3835-4f68-8fad-f2aea9ae6b71","catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","omschrijving":"PDF + Informatieobjecttype","vertrouwelijkheidaanduiding":"openbaar","beginGeldigheid":"2024-07-11","eindeGeldigheid":null,"concept":false,"besluittypen":[],"informatieobjectcategorie":"Test + category","trefwoord":[],"omschrijvingGeneriek":{"informatieobjecttypeOmschrijvingGeneriek":"","definitieInformatieobjecttypeOmschrijvingGeneriek":"","herkomstInformatieobjecttypeOmschrijvingGeneriek":"","hierarchieInformatieobjecttypeOmschrijvingGeneriek":"","opmerkingInformatieobjecttypeOmschrijvingGeneriek":""},"zaaktypen":[],"beginObject":"2024-03-19","eindeObject":null},{"url":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","omschrijving":"Attachment + Informatieobjecttype","vertrouwelijkheidaanduiding":"openbaar","beginGeldigheid":"2024-03-19","eindeGeldigheid":"2024-07-10","concept":false,"besluittypen":[],"informatieobjectcategorie":"Test + category","trefwoord":[],"omschrijvingGeneriek":{"informatieobjecttypeOmschrijvingGeneriek":"","definitieInformatieobjecttypeOmschrijvingGeneriek":"","herkomstInformatieobjecttypeOmschrijvingGeneriek":"","hierarchieInformatieobjecttypeOmschrijvingGeneriek":"","opmerkingInformatieobjecttypeOmschrijvingGeneriek":""},"zaaktypen":["http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400"],"beginObject":"2024-03-19","eindeObject":"2024-07-10"},{"url":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/b2d83b94-9b9b-4e80-a82f-73ff993c62f3","catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","omschrijving":"CSV + Informatieobjecttype","vertrouwelijkheidaanduiding":"openbaar","beginGeldigheid":"2024-03-19","eindeGeldigheid":null,"concept":false,"besluittypen":[],"informatieobjectcategorie":"Test + category","trefwoord":[],"omschrijvingGeneriek":{"informatieobjecttypeOmschrijvingGeneriek":"","definitieInformatieobjecttypeOmschrijvingGeneriek":"","herkomstInformatieobjecttypeOmschrijvingGeneriek":"","hierarchieInformatieobjecttypeOmschrijvingGeneriek":"","opmerkingInformatieobjecttypeOmschrijvingGeneriek":""},"zaaktypen":[],"beginObject":"2024-03-19","eindeObject":null},{"url":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/7a474713-0833-402a-8441-e467c08ac55b","catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","omschrijving":"PDF + Informatieobjecttype","vertrouwelijkheidaanduiding":"openbaar","beginGeldigheid":"2024-03-19","eindeGeldigheid":"2024-07-10","concept":false,"besluittypen":[],"informatieobjectcategorie":"Test + category","trefwoord":[],"omschrijvingGeneriek":{"informatieobjecttypeOmschrijvingGeneriek":"","definitieInformatieobjecttypeOmschrijvingGeneriek":"","herkomstInformatieobjecttypeOmschrijvingGeneriek":"","hierarchieInformatieobjecttypeOmschrijvingGeneriek":"","opmerkingInformatieobjecttypeOmschrijvingGeneriek":""},"zaaktypen":[],"beginObject":"2024-03-19","eindeObject":null}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '3419' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +version: 1 diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_api_endpoints.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_api_endpoints.py index 2ae24cab3a..b562c4bf3d 100644 --- a/src/openforms/registrations/contrib/zgw_apis/tests/test_api_endpoints.py +++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_api_endpoints.py @@ -232,6 +232,20 @@ def test_missing_zgw_api_group(self): self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + def test_missing_catalogue_url_with_case_type_identification(self): + user = StaffUserFactory.create() + self.client.force_login(user) + + response = self.client.get( + self.endpoint, + { + "zgw_api_group": self.zgw_api_group.pk, + "case_type_identification": "ZT-001", + }, + ) + + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + def test_retrieve_with_explicit_zgw_api_group(self): user = StaffUserFactory.create() self.client.force_login(user) @@ -257,7 +271,7 @@ def test_retrieve_filter_by_catalogus(self): self.endpoint, { "zgw_api_group": self.zgw_api_group.pk, - "catalogus_url": "http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d", + "catalogue_url": "http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d", }, ) @@ -267,6 +281,25 @@ def test_retrieve_filter_by_catalogus(self): self.assertEqual(len(data), 3) + def test_retrieve_filter_by_catalogus_and_case_type(self): + user = StaffUserFactory.create() + self.client.force_login(user) + + response = self.client.get( + self.endpoint, + { + "zgw_api_group": self.zgw_api_group.pk, + "catalogue_url": "http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d", + "case_type_identification": "ZT-001", + }, + ) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + + data = response.json() + + self.assertEqual(len(data), 1) + class GetProductsListViewTests(OFVCRMixin, APITestCase): VCR_TEST_FILES = TEST_FILES From aa61ec033815f7efddeaee38dadd971b9440f378 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Tue, 12 Nov 2024 09:55:57 +0100 Subject: [PATCH 10/18] :green_heart: [#4606] Update broken tests Tests broke due to changes in behaviour, but the assertions were not updated accordingly yet. --- .../contrib/objects_api/tests/test_api_endpoints.py | 12 ++++++------ .../tests/test_on_completion_retry_chain.py | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/openforms/registrations/contrib/objects_api/tests/test_api_endpoints.py b/src/openforms/registrations/contrib/objects_api/tests/test_api_endpoints.py index 75af39b1fb..aaccf48dd8 100644 --- a/src/openforms/registrations/contrib/objects_api/tests/test_api_endpoints.py +++ b/src/openforms/registrations/contrib/objects_api/tests/test_api_endpoints.py @@ -331,15 +331,15 @@ def test_retrieve_with_explicit_objects_api_group(self): self.assertGreaterEqual(num_document_types, 6) # assert that multiple versions are de-duplicated num_unique = len( - {(item["omschrijving"], item["catalogusLabel"]) for item in data} + {(item["description"], item["catalogueLabel"]) for item in data} ) self.assertEqual(num_unique, num_document_types) # check the data types of returned information record = data[0] expected = { - "catalogusLabel": str, - "omschrijving": str, + "catalogueLabel": str, + "description": str, "url": str, } for key, type in expected.items(): @@ -364,13 +364,13 @@ def test_retrieve_filter_by_catalogus(self): self.assertGreaterEqual(len(data), 3) # we expect only one catalogue to be returned - catalogi_labels_seen = {item["catalogusLabel"] for item in data} + catalogi_labels_seen = {item["catalogueLabel"] for item in data} self.assertEqual(len(catalogi_labels_seen), 1) # check the data types of returned information record = data[0] expected = { - "catalogusLabel": str, - "omschrijving": str, + "catalogueLabel": str, + "description": str, "url": str, } for key, type in expected.items(): diff --git a/src/openforms/submissions/tests/test_on_completion_retry_chain.py b/src/openforms/submissions/tests/test_on_completion_retry_chain.py index e8c4964e49..f1c0b5fe09 100644 --- a/src/openforms/submissions/tests/test_on_completion_retry_chain.py +++ b/src/openforms/submissions/tests/test_on_completion_retry_chain.py @@ -281,6 +281,7 @@ def test_backend_registration_succeeds(self, mock_update_payment): { "zgw_api_group": zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "objects_api_group": None, From e83677200b88e1457296d6ff486768a538296cf7 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Thu, 14 Nov 2024 12:42:06 +0100 Subject: [PATCH 11/18] :white_check_mark: [#4606] Add more test cases for document type validation --- ..._catalogus_and_case_type_doesnt_exist.yaml | 82 +++++++++++ ...e_exists_when_description_is_provided.yaml | 136 +++++++++++++++++- .../zgw_apis/tests/test_api_endpoints.py | 18 +++ .../contrib/zgw_apis/tests/test_validators.py | 33 +++++ 4 files changed, 263 insertions(+), 6 deletions(-) create mode 100644 src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/GetInformatieObjecttypesViewTests/GetInformatieObjecttypesViewTests.test_retrieve_filter_by_catalogus_and_case_type_doesnt_exist.yaml diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/GetInformatieObjecttypesViewTests/GetInformatieObjecttypesViewTests.test_retrieve_filter_by_catalogus_and_case_type_doesnt_exist.yaml b/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/GetInformatieObjecttypesViewTests/GetInformatieObjecttypesViewTests.test_retrieve_filter_by_catalogus_and_case_type_doesnt_exist.yaml new file mode 100644 index 0000000000..47363bd8f7 --- /dev/null +++ b/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/GetInformatieObjecttypesViewTests/GetInformatieObjecttypesViewTests.test_retrieve_filter_by_catalogus_and_case_type_doesnt_exist.yaml @@ -0,0 +1,82 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTU4NjQzNywiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.zymZAY0Qw_intW2qSBq4yyvVmCGUURBzqxypZ8P3ZEA + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/catalogussen?domein=VRSN + response: + body: + string: '{"count":0,"next":null,"previous":null,"results":[]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '52' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTU4NjQzNywiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.zymZAY0Qw_intW2qSBq4yyvVmCGUURBzqxypZ8P3ZEA + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/zaaktypen?catalogus=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fcatalogussen%2Fbd58635c-793e-446d-a7e0-460d7b04829d&identificatie=i-do-not-exist + response: + body: + string: '{"count":0,"next":null,"previous":null,"results":[]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '52' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +version: 1 diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/OptionsSerializerTests/OptionsSerializerTests.test_validate_document_type_exists_when_description_is_provided.yaml b/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/OptionsSerializerTests/OptionsSerializerTests.test_validate_document_type_exists_when_description_is_provided.yaml index 0ca0652891..4d5acb1708 100644 --- a/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/OptionsSerializerTests/OptionsSerializerTests.test_validate_document_type_exists_when_description_is_provided.yaml +++ b/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/OptionsSerializerTests/OptionsSerializerTests.test_validate_document_type_exists_when_description_is_provided.yaml @@ -7,7 +7,7 @@ interactions: Accept-Encoding: - gzip, deflate, br Authorization: - - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTM0NDgxNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.tAD3fE09ApDWQoGqdBBTdf8PvzqEn8PzYc9WZkL4Q5Q + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTU4NDUwNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.SQqVJwOVeNIAar3t-kXyCerY_IvkFktXmS3msrO8vlM Connection: - keep-alive User-Agent: @@ -49,7 +49,7 @@ interactions: Accept-Encoding: - gzip, deflate, br Authorization: - - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTM0NDgxNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.tAD3fE09ApDWQoGqdBBTdf8PvzqEn8PzYc9WZkL4Q5Q + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTU4NDUwNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.SQqVJwOVeNIAar3t-kXyCerY_IvkFktXmS3msrO8vlM Connection: - keep-alive User-Agent: @@ -91,7 +91,7 @@ interactions: Accept-Encoding: - gzip, deflate, br Authorization: - - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTM0NDgxNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.tAD3fE09ApDWQoGqdBBTdf8PvzqEn8PzYc9WZkL4Q5Q + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTU4NDUwNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.SQqVJwOVeNIAar3t-kXyCerY_IvkFktXmS3msrO8vlM Connection: - keep-alive User-Agent: @@ -133,7 +133,7 @@ interactions: Accept-Encoding: - gzip, deflate, br Authorization: - - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTM0NDgxNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.tAD3fE09ApDWQoGqdBBTdf8PvzqEn8PzYc9WZkL4Q5Q + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTU4NDUwNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.SQqVJwOVeNIAar3t-kXyCerY_IvkFktXmS3msrO8vlM Connection: - keep-alive User-Agent: @@ -175,7 +175,7 @@ interactions: Accept-Encoding: - gzip, deflate, br Authorization: - - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTM0NDgxNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.tAD3fE09ApDWQoGqdBBTdf8PvzqEn8PzYc9WZkL4Q5Q + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTU4NDUwNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.SQqVJwOVeNIAar3t-kXyCerY_IvkFktXmS3msrO8vlM Connection: - keep-alive User-Agent: @@ -217,7 +217,7 @@ interactions: Accept-Encoding: - gzip, deflate, br Authorization: - - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTM0NDgxNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.tAD3fE09ApDWQoGqdBBTdf8PvzqEn8PzYc9WZkL4Q5Q + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTU4NDUwNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.SQqVJwOVeNIAar3t-kXyCerY_IvkFktXmS3msrO8vlM Connection: - keep-alive User-Agent: @@ -253,4 +253,128 @@ interactions: status: code: 200 message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTU4NDUwNSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.yp8AtTeh6cfVTJSoMKI63_02CwLRveu4_8kXRU7z560 + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/catalogussen?domein=TEST&rsin=000000000 + response: + body: + string: '{"count":1,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","domein":"TEST","rsin":"000000000","contactpersoonBeheerNaam":"Test + name","contactpersoonBeheerTelefoonnummer":"","contactpersoonBeheerEmailadres":"","zaaktypen":["http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400","http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc"],"besluittypen":[],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/7a474713-0833-402a-8441-e467c08ac55b","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/b2d83b94-9b9b-4e80-a82f-73ff993c62f3","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/29b63e5c-3835-4f68-8fad-f2aea9ae6b71"],"naam":"Test + catalog","versie":"","begindatumVersie":null}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '985' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTU4NDUwNSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.yp8AtTeh6cfVTJSoMKI63_02CwLRveu4_8kXRU7z560 + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/zaaktypen?catalogus=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fcatalogussen%2Fbd58635c-793e-446d-a7e0-460d7b04829d&identificatie=ZT-001 + response: + body: + string: '{"count":2,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400","identificatie":"ZT-001","omschrijving":"Test","omschrijvingGeneriek":"","vertrouwelijkheidaanduiding":"intern","doel":"testen","aanleiding":"integratietests","toelichting":"","indicatieInternOfExtern":"intern","handelingInitiator":"Formulier + indienen","onderwerp":"Testformulier","handelingBehandelaar":"Controleren","doorlooptijd":"P1D","servicenorm":null,"opschortingEnAanhoudingMogelijk":false,"verlengingMogelijk":false,"verlengingstermijn":null,"trefwoorden":[],"publicatieIndicatie":false,"publicatietekst":"","verantwoordingsrelatie":[],"productenOfDiensten":[],"selectielijstProcestype":"https://selectielijst.openzaak.nl/api/v1/procestypen/aa8aa2fd-b9c6-4e34-9a6c-58a677f60ea0","referentieproces":{"naam":"Testen","link":""},"concept":false,"verantwoordelijke":"Ontwikkelaar","beginGeldigheid":"2023-01-01","eindeGeldigheid":"2024-03-26","versiedatum":"2023-01-01","beginObject":"2023-01-01","eindeObject":null,"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","statustypen":["http://localhost:8003/catalogi/api/v1/statustypen/d1ce96ef-325d-4e2f-a325-d7ed017f3b81","http://localhost:8003/catalogi/api/v1/statustypen/658becc5-fab6-43ad-8289-2beff5c65945"],"resultaattypen":["http://localhost:8003/catalogi/api/v1/resultaattypen/ec03d4e6-c010-4163-9c05-8247def5f45c"],"eigenschappen":["http://localhost:8003/catalogi/api/v1/eigenschappen/7eada907-ffb7-4846-9494-68eb1452182c"],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"],"roltypen":["http://localhost:8003/catalogi/api/v1/roltypen/0333eec0-6240-4f90-adf9-8f98edcd5563","http://localhost:8003/catalogi/api/v1/roltypen/cebf7a53-297d-4308-869a-4385cfc42549"],"besluittypen":[],"deelzaaktypen":[],"gerelateerdeZaaktypen":[],"zaakobjecttypen":[]},{"url":"http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","identificatie":"ZT-001","omschrijving":"Test","omschrijvingGeneriek":"","vertrouwelijkheidaanduiding":"intern","doel":"testen","aanleiding":"integratietests","toelichting":"","indicatieInternOfExtern":"intern","handelingInitiator":"Formulier + indienen","onderwerp":"Testformulier","handelingBehandelaar":"Controleren","doorlooptijd":"P1D","servicenorm":null,"opschortingEnAanhoudingMogelijk":false,"verlengingMogelijk":false,"verlengingstermijn":null,"trefwoorden":[],"publicatieIndicatie":false,"publicatietekst":"","verantwoordingsrelatie":[],"productenOfDiensten":[],"selectielijstProcestype":"https://selectielijst.openzaak.nl/api/v1/procestypen/aa8aa2fd-b9c6-4e34-9a6c-58a677f60ea0","referentieproces":{"naam":"Testen","link":""},"concept":false,"verantwoordelijke":"Ontwikkelaar","beginGeldigheid":"2024-03-26","eindeGeldigheid":null,"versiedatum":"2024-03-26","beginObject":"2023-01-01","eindeObject":null,"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","statustypen":["http://localhost:8003/catalogi/api/v1/statustypen/1de05b57-a938-47e4-b808-f129c6406b60","http://localhost:8003/catalogi/api/v1/statustypen/6443ac1a-04a1-4335-9db2-5f3c998dbb34"],"resultaattypen":["http://localhost:8003/catalogi/api/v1/resultaattypen/65b7cedd-5729-41bd-b9c7-1f51d7583340"],"eigenschappen":["http://localhost:8003/catalogi/api/v1/eigenschappen/b659caed-e39e-47e3-ac51-bc8bd2ad797e"],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"],"roltypen":["http://localhost:8003/catalogi/api/v1/roltypen/43e8026c-8abd-4b29-8a4c-ac2a37bc6f5b","http://localhost:8003/catalogi/api/v1/roltypen/7f1887e8-bf22-47e7-ae52-ed6848d7e70e"],"besluittypen":[],"deelzaaktypen":[],"gerelateerdeZaaktypen":[],"zaakobjecttypen":[]}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '3897' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTU4NDUwNSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.yp8AtTeh6cfVTJSoMKI63_02CwLRveu4_8kXRU7z560 + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/informatieobjecttypen?catalogus=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fcatalogussen%2Fbd58635c-793e-446d-a7e0-460d7b04829d&omschrijving=i-do-not-exist + response: + body: + string: '{"count":0,"next":null,"previous":null,"results":[]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '52' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK version: 1 diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_api_endpoints.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_api_endpoints.py index b562c4bf3d..271aa463f2 100644 --- a/src/openforms/registrations/contrib/zgw_apis/tests/test_api_endpoints.py +++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_api_endpoints.py @@ -300,6 +300,24 @@ def test_retrieve_filter_by_catalogus_and_case_type(self): self.assertEqual(len(data), 1) + def test_retrieve_filter_by_catalogus_and_case_type_doesnt_exist(self): + user = StaffUserFactory.create() + self.client.force_login(user) + + response = self.client.get( + self.endpoint, + { + "zgw_api_group": self.zgw_api_group.pk, + "catalogue_url": "http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d", + "case_type_identification": "i-do-not-exist", + }, + ) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + + self.assertEqual(data, []) + class GetProductsListViewTests(OFVCRMixin, APITestCase): VCR_TEST_FILES = TEST_FILES diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_validators.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_validators.py index 8c26365583..b4b66808e6 100644 --- a/src/openforms/registrations/contrib/zgw_apis/tests/test_validators.py +++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_validators.py @@ -552,6 +552,25 @@ def test_validation_objecttype_api_root_must_match_objecttypes_service_api_root( err = serializer.errors["objecttype"][0] self.assertEqual(err.code, "invalid") + def test_document_type_must_be_provided(self): + # either informatieobjecttype or document_type_description must be provided + data = { + "zgw_api_group": self.zgw_group.pk, + "catalogue": { + "domain": "TEST", + "rsin": "000000000", + }, + "case_type_identification": "ZT-001", + } + serializer = ZaakOptionsSerializer(data=data) + + is_valid = serializer.is_valid() + + self.assertFalse(is_valid) + self.assertIn("document_type_description", serializer.errors) + err = serializer.errors["document_type_description"][0] + self.assertEqual(err.code, "required") + def test_validate_document_type_exists_when_description_is_provided(self): base = { "zgw_api_group": self.zgw_group.pk, @@ -586,3 +605,17 @@ def test_validate_document_type_exists_when_description_is_provided(self): self.assertIn("document_type_description", serializer.errors) err = serializer.errors["document_type_description"][0] self.assertEqual(err.code, "not-found") + + with self.subTest("document type does not exist"): + data = { + **base, + "document_type_description": "i-do-not-exist", + } + serializer = ZaakOptionsSerializer(data=data) + + is_valid = serializer.is_valid() + + self.assertFalse(is_valid) + self.assertIn("document_type_description", serializer.errors) + err = serializer.errors["document_type_description"][0] + self.assertEqual(err.code, "not-found") From 34c2fc8c07fd1bf9bfff9f49e6604c5903cec33c Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Thu, 14 Nov 2024 16:44:53 +0100 Subject: [PATCH 12/18] :label: [#4606] Type-check zgw tests modules --- pyright.pyproject.toml | 3 +- .../contrib/zgw_apis/tests/factories.py | 2 +- .../contrib/zgw_apis/tests/test_backend.py | 32 ++++++++++++++++++- .../tests/test_backend_partial_failure.py | 2 +- .../zgw_apis/tests/test_zgw_api_config.py | 18 ++++++++--- 5 files changed, 49 insertions(+), 8 deletions(-) diff --git a/pyright.pyproject.toml b/pyright.pyproject.toml index 4101b46999..0798880dcf 100644 --- a/pyright.pyproject.toml +++ b/pyright.pyproject.toml @@ -45,7 +45,8 @@ include = [ exclude = [ "**/__pycache__", "src/openforms/formio/formatters/tests/", - "src/openforms/registrations/contrib/zgw_apis/tests/", + "src/openforms/registrations/contrib/zgw_apis/tests/test_backend_partial_failure.py", + "src/openforms/registrations/contrib/zgw_apis/tests/test_utils.py", ] ignore = [] diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/factories.py b/src/openforms/registrations/contrib/zgw_apis/tests/factories.py index 7bfebfb97f..67c1cb943c 100644 --- a/src/openforms/registrations/contrib/zgw_apis/tests/factories.py +++ b/src/openforms/registrations/contrib/zgw_apis/tests/factories.py @@ -17,7 +17,7 @@ class ZGWApiGroupConfigFactory(factory.django.DjangoModelFactory): "zgw_consumers.test.factories.ServiceFactory", api_type=APITypes.ztc ) - class Meta: + class Meta: # pyright: ignore[reportIncompatibleVariableOverride] model = ZGWApiGroupConfig class Params: diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py index 00979657d3..31bd3ad8f4 100644 --- a/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py +++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py @@ -242,6 +242,7 @@ def test_submission_with_zgw_backend_with_natuurlijk_persoon_initiator(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "organisatie_rsin": "000000000", @@ -256,6 +257,8 @@ def test_submission_with_zgw_backend_with_natuurlijk_persoon_initiator(self, m): pre_registration_result = plugin.pre_register_submission( submission, zgw_form_options ) + assert submission.registration_result is not None + assert isinstance(pre_registration_result.data, dict) submission.registration_result.update(pre_registration_result.data) submission.save() result = plugin.register_submission(submission, zgw_form_options) @@ -466,6 +469,7 @@ def test_submission_with_zgw_backend_with_vestiging_and_kvk_initiator(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "organisatie_rsin": "000000000", @@ -480,6 +484,8 @@ def test_submission_with_zgw_backend_with_vestiging_and_kvk_initiator(self, m): pre_registration_result = plugin.pre_register_submission( submission, zgw_form_options ) + assert submission.registration_result is not None + assert isinstance(pre_registration_result.data, dict) submission.registration_result.update(pre_registration_result.data) submission.save() result = plugin.register_submission(submission, zgw_form_options) @@ -676,6 +682,7 @@ def test_submission_with_zgw_backend_with_kvk_only_initiator(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "organisatie_rsin": "000000000", @@ -756,6 +763,7 @@ def test_submission_with_zgw_backend_with_vestiging_initiator_kvk_only(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "organisatie_rsin": "000000000", @@ -770,6 +778,8 @@ def test_submission_with_zgw_backend_with_vestiging_initiator_kvk_only(self, m): pre_registration_result = plugin.pre_register_submission( submission, zgw_form_options ) + assert submission.registration_result is not None + assert isinstance(pre_registration_result.data, dict) submission.registration_result.update(pre_registration_result.data) submission.save() result = plugin.register_submission(submission, zgw_form_options) @@ -966,6 +976,7 @@ def test_submission_with_registrator(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "organisatie_rsin": "000000000", @@ -1093,6 +1104,7 @@ def test_submission_roltype_initiator_not_found(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "organisatie_rsin": "000000000", @@ -1142,7 +1154,7 @@ def test_retried_registration_with_internal_reference(self, m): ) self.install_mocks(m) - pre_registration(submission.id, PostSubmissionEvents.on_retry) + pre_registration(submission.pk, PostSubmissionEvents.on_retry) create_zaak = m.request_history[0] create_zaak_body = create_zaak.json() @@ -1168,6 +1180,7 @@ def test_register_and_update_paid_product(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "organisatie_rsin": "000000000", @@ -1194,6 +1207,8 @@ def test_register_and_update_paid_product(self, m): ) submission.public_registration_reference = pre_registration_result.reference + assert submission.registration_result is not None + assert isinstance(pre_registration_result.data, dict) submission.registration_result.update(pre_registration_result.data) submission.save() @@ -1255,6 +1270,7 @@ def test_submission_with_zgw_backend_override_fields(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "organisatie_rsin": "000000000", @@ -1366,6 +1382,7 @@ def test_zgw_backend_default_author(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "objects_api_group": None, @@ -1440,6 +1457,7 @@ def test_zgw_backend_document_ontvangstdatum(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "objects_api_group": None, @@ -1494,6 +1512,7 @@ def test_zgw_backend_defaults_empty_string(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "auteur": "", @@ -1529,6 +1548,7 @@ def test_zgw_backend_unspecified_zaakvertrouwelijkheidaanduiding(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "auteur": "", @@ -1590,6 +1610,7 @@ def test_document_size_argument_present(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "organisatie_rsin": "000000000", @@ -1613,6 +1634,8 @@ def test_document_size_argument_present(self, m): ) submission.public_registration_reference = pre_registration_result.reference + assert submission.registration_result is not None + assert isinstance(pre_registration_result.data, dict) submission.registration_result.update(pre_registration_result.data) submission.save() @@ -1802,6 +1825,7 @@ def get_create_json_for_zaakobject(req, ctx): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "organisatie_rsin": "000000000", @@ -1915,6 +1939,7 @@ def test_submission_with_multiple_eigenschappen_creation(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "organisatie_rsin": "000000000", @@ -2121,6 +2146,7 @@ def test_submission_with_nested_component_columns_and_eigenschap(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "organisatie_rsin": "000000000", @@ -2351,6 +2377,7 @@ def test_zgw_backend_zaak_omschrijving(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "auteur": "", @@ -2378,6 +2405,7 @@ def test_zgw_backend_zaak_omschrijving(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "auteur": "", @@ -2438,6 +2466,7 @@ def test_create_zaak_with_case_identification_reference(self): "rsin": "000000000", }, "case_type_identification": "ZT-001", + "document_type_description": "", "zaaktype": "", "informatieobjecttype": ( "http://localhost:8003/catalogi/api/v1/" @@ -2584,6 +2613,7 @@ def test_allow_registration_with_unpublished_case_types(self): options: RegistrationOptions = { "zgw_api_group": zgw_group, "case_type_identification": "DRAFT-01", + "document_type_description": "", "zaaktype": "", "informatieobjecttype": ( "http://localhost:8003/catalogi/api/v1/" diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_backend_partial_failure.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_backend_partial_failure.py index ff3f4052f2..13377e8224 100644 --- a/src/openforms/registrations/contrib/zgw_apis/tests/test_backend_partial_failure.py +++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_backend_partial_failure.py @@ -669,7 +669,7 @@ def get_create_json_for_object(req, ctx): @requests_mock.Mocker() -class eigenschappenPartialRegistrationFailureTests(TestCase): +class EigenschappenPartialRegistrationFailureTests(TestCase): def test_failure_after_eigenschappen_retrieval(self, m): zgw_api_group = ZGWApiGroupConfigFactory.create( zrc_service__api_root="https://zaken.nl/api/v1/", diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_zgw_api_config.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_zgw_api_config.py index 8d51036c55..0f37b389e7 100644 --- a/src/openforms/registrations/contrib/zgw_apis/tests/test_zgw_api_config.py +++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_zgw_api_config.py @@ -7,6 +7,7 @@ from zgw_consumers.test import generate_oas_component from openforms.plugins.exceptions import InvalidPluginConfiguration +from openforms.registrations.tasks import pre_registration from openforms.submissions.tests.factories import ( SubmissionFactory, SubmissionFileAttachmentFactory, @@ -322,6 +323,7 @@ def test_the_right_api_is_used(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group2, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi-2.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi-2.nl/api/v1/informatieobjecttypen/1", "objects_api_group": None, @@ -334,6 +336,8 @@ def test_the_right_api_is_used(self, m): submission, zgw_form_options ) + assert submission.registration_result is not None + assert isinstance(pre_registration_result.data, dict) submission.public_registration_reference = pre_registration_result.reference submission.registration_result.update(pre_registration_result.data) submission.save() @@ -359,11 +363,12 @@ def test_per_form_overwrites(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group2, # Configure to use the second ZGW API "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi-2.nl/api/v1/zaaktypen/2", "informatieobjecttype": "https://catalogi-2.nl/api/v1/informatieobjecttypen/2", "organisatie_rsin": "000000123", - "zaak_vertrouwelijkheidaanduiding": VertrouwelijkheidsAanduidingen.confidentieel, # type: ignore - "doc_vertrouwelijkheidaanduiding": VertrouwelijkheidsAanduidingen.geheim, # type: ignore + "zaak_vertrouwelijkheidaanduiding": "confidentieel", + "doc_vertrouwelijkheidaanduiding": "geheim", "objects_api_group": None, "product_url": "", } @@ -375,6 +380,8 @@ def test_per_form_overwrites(self, m): submission, zgw_form_options ) + assert submission.registration_result is not None + assert isinstance(pre_registration_result.data, dict) submission.public_registration_reference = pre_registration_result.reference submission.registration_result.update(pre_registration_result.data) submission.save() @@ -451,11 +458,12 @@ def test_uses_field_overwrites_for_documents(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group2, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi-2.nl/api/v1/zaaktypen/2", "informatieobjecttype": "https://catalogi-2.nl/api/v1/informatieobjecttypen/2", "organisatie_rsin": "000000123", - "zaak_vertrouwelijkheidaanduiding": VertrouwelijkheidsAanduidingen.confidentieel, # type: ignore - "doc_vertrouwelijkheidaanduiding": VertrouwelijkheidsAanduidingen.geheim, # type: ignore + "zaak_vertrouwelijkheidaanduiding": "confidentieel", + "doc_vertrouwelijkheidaanduiding": "geheim", "objects_api_group": None, "product_url": "", } @@ -466,6 +474,8 @@ def test_uses_field_overwrites_for_documents(self, m): submission, zgw_form_options ) + assert submission.registration_result is not None + assert isinstance(pre_registration_result.data, dict) submission.public_registration_reference = pre_registration_result.reference submission.registration_result.update(pre_registration_result.data) submission.save() From bc17639121e0ddb8582e96d7e6c1f1caa28eb2af Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Thu, 14 Nov 2024 17:07:41 +0100 Subject: [PATCH 13/18] :recycle: [#4606] Refactor case type resolution into private helper --- .../registrations/contrib/zgw_apis/plugin.py | 56 ++++++++++++------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/src/openforms/registrations/contrib/zgw_apis/plugin.py b/src/openforms/registrations/contrib/zgw_apis/plugin.py index fb67272dd5..de440317ba 100644 --- a/src/openforms/registrations/contrib/zgw_apis/plugin.py +++ b/src/openforms/registrations/contrib/zgw_apis/plugin.py @@ -1,4 +1,5 @@ import logging +from datetime import datetime from functools import partial, wraps from typing import Any, TypedDict @@ -15,6 +16,7 @@ from openforms.contrib.objects_api.helpers import prepare_data_for_registration from openforms.contrib.objects_api.rendering import render_to_json from openforms.contrib.zgw.clients.catalogi import ( + CatalogiClient, EigenschapSpecificatie, omschrijving_matcher, ) @@ -37,7 +39,7 @@ from .client import get_catalogi_client, get_documents_client, get_zaken_client from .models import ZGWApiGroupConfig from .options import ZaakOptionsSerializer -from .typing import RegistrationOptions +from .typing import CatalogueOption, RegistrationOptions from .utils import process_according_to_eigenschap_format logger = logging.getLogger(__name__) @@ -105,6 +107,34 @@ class _Eigenschap(TypedDict): specificatie: EigenschapSpecificatie +def _resolve_case_type( + catalogi_client: CatalogiClient, + catalogue: CatalogueOption, + identification: str, + submission_completed: datetime, +): + version_valid_on = datetime_in_amsterdam(submission_completed).date() + + catalogus = catalogi_client.find_catalogus(**catalogue) + if catalogus is None: + raise RuntimeError(f"Could not resolve catalogue {catalogue}") + versions = catalogi_client.find_case_types( + catalogus=catalogus["url"], + identification=identification, + valid_on=version_valid_on, + ) + + if versions is None: + raise RuntimeError( + "Could not find a case type with identification " + f"'{identification}' that is valid on " + f"{version_valid_on.isoformat()}." + ) + + version = versions[0] + return version["url"] + + @register("zgw-create-zaak") class ZGWRegistration(BasePlugin[RegistrationOptions]): verbose_name = _("ZGW API's") @@ -180,27 +210,13 @@ def pre_register_submission( if case_type_identification := options["case_type_identification"]: catalogue = options.get("catalogue") assert catalogue is not None # enforced by validation - version_valid_on = datetime_in_amsterdam(submission.completed_on).date() - with get_catalogi_client(zgw) as catalogi_client: - catalogus = catalogi_client.find_catalogus(**catalogue) - if catalogus is None: - raise RuntimeError(f"Could not resolve catalogue {catalogue}") - versions = catalogi_client.find_case_types( - catalogus=catalogus["url"], - identification=case_type_identification, - valid_on=version_valid_on, - ) - - if versions is None: - raise RuntimeError( - "Could not find a case type with identification " - f"'{case_type_identification}' that is valid on " - f"{version_valid_on.isoformat()}." + zaaktype_url = _resolve_case_type( + catalogi_client, + catalogue, + case_type_identification, + submission.completed_on, ) - - version = versions[0] - zaaktype_url = version["url"] else: zaaktype_url = options["zaaktype"] From 1202969daf6d3081c693a8158daf93d82ba189cd Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Thu, 14 Nov 2024 17:32:30 +0100 Subject: [PATCH 14/18] :sparkles: [#4606] Implement dynamically resolving the document type The specified document type is now dynamically resolved within the case type of the created case, using the submissions completion time to determine the correct version to use. The legacy configuration options now emit deprecation warnings, but will still be supported for the foreseeable future. --- src/openforms/contrib/zgw/clients/catalogi.py | 14 + .../registrations/contrib/zgw_apis/plugin.py | 62 +- ...h_document_type_description_reference.yaml | 781 ++++++++++++++++++ .../contrib/zgw_apis/tests/test_backend.py | 69 +- .../zgw_apis/tests/test_zgw_api_config.py | 1 - 5 files changed, 922 insertions(+), 5 deletions(-) create mode 100644 src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/ZGWBackendVCRTests/ZGWBackendVCRTests.test_create_document_with_document_type_description_reference.yaml diff --git a/src/openforms/contrib/zgw/clients/catalogi.py b/src/openforms/contrib/zgw/clients/catalogi.py index 9325234b19..a6ab02329f 100644 --- a/src/openforms/contrib/zgw/clients/catalogi.py +++ b/src/openforms/contrib/zgw/clients/catalogi.py @@ -251,6 +251,7 @@ def find_informatieobjecttypen( catalogus: str, description: str, valid_on: date | None = None, + within_casetype: str = "", # URL reference of a case type ) -> list[InformatieObjectType] | None: """ Look up an informatieobjecttype within the specified catalogue. @@ -300,6 +301,19 @@ def find_informatieobjecttypen( f"'{description}'. Version (date) ranges may not overlap." ) + if within_casetype: + # Filter down the options to those present in the requested case type + case_type_response = self.get(within_casetype) + case_type_response.raise_for_status() + case_type: CaseType = case_type_response.json() + case_type_document_types = case_type.get("informatieobjecttypen", []) + + all_versions = [ + version + for version in all_versions + if version["url"] in case_type_document_types + ] + return all_versions def list_statustypen(self, zaaktype: str) -> list[dict]: diff --git a/src/openforms/registrations/contrib/zgw_apis/plugin.py b/src/openforms/registrations/contrib/zgw_apis/plugin.py index de440317ba..b33a77b173 100644 --- a/src/openforms/registrations/contrib/zgw_apis/plugin.py +++ b/src/openforms/registrations/contrib/zgw_apis/plugin.py @@ -1,4 +1,5 @@ import logging +import warnings from datetime import datetime from functools import partial, wraps from typing import Any, TypedDict @@ -112,7 +113,7 @@ def _resolve_case_type( catalogue: CatalogueOption, identification: str, submission_completed: datetime, -): +) -> str: version_valid_on = datetime_in_amsterdam(submission_completed).date() catalogus = catalogi_client.find_catalogus(**catalogue) @@ -135,6 +136,37 @@ def _resolve_case_type( return version["url"] +def _resolve_document_type( + catalogi_client: CatalogiClient, + catalogue: CatalogueOption, + zaaktype_url: str, + description: str, + submission_completed: datetime, +): + version_valid_on = datetime_in_amsterdam(submission_completed).date() + + catalogus = catalogi_client.find_catalogus(**catalogue) + if catalogus is None: + raise RuntimeError(f"Could not resolve catalogue {catalogue}") + versions = catalogi_client.find_informatieobjecttypen( + catalogus=catalogus["url"], + description=description, + valid_on=version_valid_on, + within_casetype=zaaktype_url, + ) + if versions is None: + raise RuntimeError( + "Could not find a document type with description " + f"'{description}' in the case type that is valid on " + f"{version_valid_on.isoformat()}." + ) + + # the client enforces there's a single version returned when a valid_on date is + # passed. + version = versions[0] + return version["url"] + + @register("zgw-create-zaak") class ZGWRegistration(BasePlugin[RegistrationOptions]): verbose_name = _("ZGW API's") @@ -218,6 +250,11 @@ def pre_register_submission( submission.completed_on, ) else: + warnings.warn( + "Using the zaaktype URL option is deprecated and will be removed in " + "Open Forms 4.0.", + DeprecationWarning, + ) zaaktype_url = options["zaaktype"] with get_zaken_client(zgw) as zaken_client: @@ -295,9 +332,28 @@ def register_submission( get_zaken_client(zgw) as zaken_client, get_catalogi_client(zgw) as catalogi_client, ): + # resolve (default) document type to use + if document_type_description := options["document_type_description"]: + catalogue = options.get("catalogue") + assert catalogue is not None # enforced by validation + informatieobjecttype_url = _resolve_document_type( + catalogi_client, + catalogue=catalogue, + zaaktype_url=zaak["zaaktype"], + description=document_type_description, + submission_completed=submission.completed_on, + ) + else: + warnings.warn( + "Using the informatieobjecttype URL option is deprecated and will " + "be removed in Open Forms 4.0.", + DeprecationWarning, + ) + informatieobjecttype_url = options["informatieobjecttype"] + # Upload the summary PDF pdf_options: DocumentOptions = { - "informatieobjecttype": options["informatieobjecttype"], + "informatieobjecttype": informatieobjecttype_url, "organisatie_rsin": options["organisatie_rsin"], "auteur": options["auteur"], "doc_vertrouwelijkheidaanduiding": options[ @@ -387,7 +443,7 @@ def register_submission( for attachment in submission.attachments: # collect attributes of the attachment and add them to the configuration # attribute names conform to the Documenten API specification - iot = attachment.informatieobjecttype or options["informatieobjecttype"] + iot = attachment.informatieobjecttype or informatieobjecttype_url bronorganisatie = ( attachment.bronorganisatie or options["organisatie_rsin"] ) diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/ZGWBackendVCRTests/ZGWBackendVCRTests.test_create_document_with_document_type_description_reference.yaml b/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/ZGWBackendVCRTests/ZGWBackendVCRTests.test_create_document_with_document_type_description_reference.yaml new file mode 100644 index 0000000000..ad658b3c15 --- /dev/null +++ b/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/ZGWBackendVCRTests/ZGWBackendVCRTests.test_create_document_with_document_type_description_reference.yaml @@ -0,0 +1,781 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/catalogussen?domein=TEST&rsin=000000000 + response: + body: + string: '{"count":1,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","domein":"TEST","rsin":"000000000","contactpersoonBeheerNaam":"Test + name","contactpersoonBeheerTelefoonnummer":"","contactpersoonBeheerEmailadres":"","zaaktypen":["http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400","http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc"],"besluittypen":[],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/7a474713-0833-402a-8441-e467c08ac55b","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/b2d83b94-9b9b-4e80-a82f-73ff993c62f3","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/29b63e5c-3835-4f68-8fad-f2aea9ae6b71"],"naam":"Test + catalog","versie":"","begindatumVersie":null}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '985' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/zaaktypen?catalogus=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fcatalogussen%2Fbd58635c-793e-446d-a7e0-460d7b04829d&identificatie=ZT-001&datumGeldigheid=2024-06-09 + response: + body: + string: '{"count":1,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","identificatie":"ZT-001","omschrijving":"Test","omschrijvingGeneriek":"","vertrouwelijkheidaanduiding":"intern","doel":"testen","aanleiding":"integratietests","toelichting":"","indicatieInternOfExtern":"intern","handelingInitiator":"Formulier + indienen","onderwerp":"Testformulier","handelingBehandelaar":"Controleren","doorlooptijd":"P1D","servicenorm":null,"opschortingEnAanhoudingMogelijk":false,"verlengingMogelijk":false,"verlengingstermijn":null,"trefwoorden":[],"publicatieIndicatie":false,"publicatietekst":"","verantwoordingsrelatie":[],"productenOfDiensten":[],"selectielijstProcestype":"https://selectielijst.openzaak.nl/api/v1/procestypen/aa8aa2fd-b9c6-4e34-9a6c-58a677f60ea0","referentieproces":{"naam":"Testen","link":""},"concept":false,"verantwoordelijke":"Ontwikkelaar","beginGeldigheid":"2024-03-26","eindeGeldigheid":null,"versiedatum":"2024-03-26","beginObject":"2023-01-01","eindeObject":null,"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","statustypen":["http://localhost:8003/catalogi/api/v1/statustypen/1de05b57-a938-47e4-b808-f129c6406b60","http://localhost:8003/catalogi/api/v1/statustypen/6443ac1a-04a1-4335-9db2-5f3c998dbb34"],"resultaattypen":["http://localhost:8003/catalogi/api/v1/resultaattypen/65b7cedd-5729-41bd-b9c7-1f51d7583340"],"eigenschappen":["http://localhost:8003/catalogi/api/v1/eigenschappen/b659caed-e39e-47e3-ac51-bc8bd2ad797e"],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"],"roltypen":["http://localhost:8003/catalogi/api/v1/roltypen/43e8026c-8abd-4b29-8a4c-ac2a37bc6f5b","http://localhost:8003/catalogi/api/v1/roltypen/7f1887e8-bf22-47e7-ae52-ed6848d7e70e"],"besluittypen":[],"deelzaaktypen":[],"gerelateerdeZaaktypen":[],"zaakobjecttypen":[]}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '1970' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: '{"zaaktype": "http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc", + "bronorganisatie": "000000000", "verantwoordelijkeOrganisatie": "000000000", + "registratiedatum": "2024-11-14", "startdatum": "2024-11-14", "omschrijving": + "Form 000", "toelichting": "Aangemaakt door Open Formulieren", "betalingsindicatie": + "nvt"}' + headers: + Accept: + - '*/*' + Accept-Crs: + - EPSG:4326 + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + Content-Crs: + - EPSG:4326 + Content-Length: + - '347' + Content-Type: + - application/json + User-Agent: + - python-requests/2.32.2 + method: POST + uri: http://localhost:8003/zaken/api/v1/zaken + response: + body: + string: '{"url":"http://localhost:8003/zaken/api/v1/zaken/4c23542d-2f57-4e3a-922b-896f107d5b10","uuid":"4c23542d-2f57-4e3a-922b-896f107d5b10","identificatie":"ZAAK-2024-0000000019","bronorganisatie":"000000000","omschrijving":"Form + 000","toelichting":"Aangemaakt door Open Formulieren","zaaktype":"http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","registratiedatum":"2024-11-14","verantwoordelijkeOrganisatie":"000000000","startdatum":"2024-11-14","einddatum":null,"einddatumGepland":null,"uiterlijkeEinddatumAfdoening":null,"publicatiedatum":null,"communicatiekanaal":"","communicatiekanaalNaam":"","productenOfDiensten":[],"vertrouwelijkheidaanduiding":"intern","betalingsindicatie":"nvt","betalingsindicatieWeergave":"Er + is geen sprake van te betalen, met de zaak gemoeide, kosten.","laatsteBetaaldatum":null,"zaakgeometrie":null,"verlenging":null,"opschorting":{"indicatie":false,"reden":""},"selectielijstklasse":"","hoofdzaak":null,"deelzaken":[],"relevanteAndereZaken":[],"eigenschappen":[],"rollen":[],"status":null,"zaakinformatieobjecten":[],"zaakobjecten":[],"kenmerken":[],"archiefnominatie":null,"archiefstatus":"nog_te_archiveren","archiefactiedatum":null,"resultaat":null,"opdrachtgevendeOrganisatie":"","processobjectaard":"","startdatumBewaartermijn":null,"processobject":{"datumkenmerk":"","identificatie":"","objecttype":"","registratie":""}}' + headers: + API-version: + - 1.5.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Crs: + - EPSG:4326 + Content-Length: + - '1389' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Location: + - http://localhost:8003/zaken/api/v1/zaken/4c23542d-2f57-4e3a-922b-896f107d5b10 + Referrer-Policy: + - same-origin + Vary: + - origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/catalogussen?domein=TEST&rsin=000000000 + response: + body: + string: '{"count":1,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","domein":"TEST","rsin":"000000000","contactpersoonBeheerNaam":"Test + name","contactpersoonBeheerTelefoonnummer":"","contactpersoonBeheerEmailadres":"","zaaktypen":["http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400","http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc"],"besluittypen":[],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/7a474713-0833-402a-8441-e467c08ac55b","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/b2d83b94-9b9b-4e80-a82f-73ff993c62f3","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/29b63e5c-3835-4f68-8fad-f2aea9ae6b71"],"naam":"Test + catalog","versie":"","begindatumVersie":null}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '985' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/informatieobjecttypen?catalogus=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fcatalogussen%2Fbd58635c-793e-446d-a7e0-460d7b04829d&omschrijving=Attachment+Informatieobjecttype&datumGeldigheid=2024-06-09 + response: + body: + string: '{"count":1,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","omschrijving":"Attachment + Informatieobjecttype","vertrouwelijkheidaanduiding":"openbaar","beginGeldigheid":"2024-03-19","eindeGeldigheid":"2024-07-10","concept":false,"besluittypen":[],"informatieobjectcategorie":"Test + category","trefwoord":[],"omschrijvingGeneriek":{"informatieobjecttypeOmschrijvingGeneriek":"","definitieInformatieobjecttypeOmschrijvingGeneriek":"","herkomstInformatieobjecttypeOmschrijvingGeneriek":"","hierarchieInformatieobjecttypeOmschrijvingGeneriek":"","opmerkingInformatieobjecttypeOmschrijvingGeneriek":""},"zaaktypen":["http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400"],"beginObject":"2024-03-19","eindeObject":"2024-07-10"}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '1038' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc + response: + body: + string: '{"url":"http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","identificatie":"ZT-001","omschrijving":"Test","omschrijvingGeneriek":"","vertrouwelijkheidaanduiding":"intern","doel":"testen","aanleiding":"integratietests","toelichting":"","indicatieInternOfExtern":"intern","handelingInitiator":"Formulier + indienen","onderwerp":"Testformulier","handelingBehandelaar":"Controleren","doorlooptijd":"P1D","servicenorm":null,"opschortingEnAanhoudingMogelijk":false,"verlengingMogelijk":false,"verlengingstermijn":null,"trefwoorden":[],"publicatieIndicatie":false,"publicatietekst":"","verantwoordingsrelatie":[],"productenOfDiensten":[],"selectielijstProcestype":"https://selectielijst.openzaak.nl/api/v1/procestypen/aa8aa2fd-b9c6-4e34-9a6c-58a677f60ea0","referentieproces":{"naam":"Testen","link":""},"concept":false,"verantwoordelijke":"Ontwikkelaar","beginGeldigheid":"2024-03-26","eindeGeldigheid":null,"versiedatum":"2024-03-26","beginObject":"2023-01-01","eindeObject":null,"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","statustypen":["http://localhost:8003/catalogi/api/v1/statustypen/1de05b57-a938-47e4-b808-f129c6406b60","http://localhost:8003/catalogi/api/v1/statustypen/6443ac1a-04a1-4335-9db2-5f3c998dbb34"],"resultaattypen":["http://localhost:8003/catalogi/api/v1/resultaattypen/65b7cedd-5729-41bd-b9c7-1f51d7583340"],"eigenschappen":["http://localhost:8003/catalogi/api/v1/eigenschappen/b659caed-e39e-47e3-ac51-bc8bd2ad797e"],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"],"roltypen":["http://localhost:8003/catalogi/api/v1/roltypen/43e8026c-8abd-4b29-8a4c-ac2a37bc6f5b","http://localhost:8003/catalogi/api/v1/roltypen/7f1887e8-bf22-47e7-ae52-ed6848d7e70e"],"besluittypen":[],"deelzaaktypen":[],"gerelateerdeZaaktypen":[],"zaakobjecttypen":[]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Content-Length: + - '1918' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + ETag: + - '"f87ecf2c8f09032a727b95863898216e"' + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: '{"informatieobjecttype": "http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7", + "bronorganisatie": "000000000", "creatiedatum": "2024-11-14", "titel": "Form + 000", "auteur": "Aanvrager", "taal": "nld", "formaat": "application/pdf", "inhoud": + "", "status": "definitief", "bestandsnaam": "open-forms-Form 000.pdf", "ontvangstdatum": + null, "beschrijving": "Ingezonden formulier", "indicatieGebruiksrecht": false, + "bestandsomvang": 0}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + Content-Length: + - '474' + Content-Type: + - application/json + User-Agent: + - python-requests/2.32.2 + method: POST + uri: http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten + response: + body: + string: '{"url":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/4dbb88e3-b00f-4d4f-8e40-253efefd11b8","identificatie":"DOCUMENT-2024-0000000081","bronorganisatie":"000000000","creatiedatum":"2024-11-14","titel":"Form + 000","vertrouwelijkheidaanduiding":"openbaar","auteur":"Aanvrager","status":"definitief","formaat":"application/pdf","taal":"nld","versie":1,"beginRegistratie":"2024-11-14T16:30:34.885872Z","bestandsnaam":"open-forms-Form + 000.pdf","inhoud":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/4dbb88e3-b00f-4d4f-8e40-253efefd11b8/download?versie=1","bestandsomvang":0,"link":"","beschrijving":"Ingezonden + formulier","ontvangstdatum":null,"verzenddatum":null,"indicatieGebruiksrecht":false,"verschijningsvorm":"","ondertekening":{"soort":"","datum":null},"integriteit":{"algoritme":"","waarde":"","datum":null},"informatieobjecttype":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","locked":false,"bestandsdelen":[],"trefwoorden":[],"lock":""}' + headers: + API-version: + - 1.4.2 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '1042' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Location: + - http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/4dbb88e3-b00f-4d4f-8e40-253efefd11b8 + Referrer-Policy: + - same-origin + Vary: + - origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 201 + message: Created +- request: + body: '{"zaak": "http://localhost:8003/zaken/api/v1/zaken/4c23542d-2f57-4e3a-922b-896f107d5b10", + "informatieobject": "http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/4dbb88e3-b00f-4d4f-8e40-253efefd11b8"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + Content-Length: + - '219' + Content-Type: + - application/json + User-Agent: + - python-requests/2.32.2 + method: POST + uri: http://localhost:8003/zaken/api/v1/zaakinformatieobjecten + response: + body: + string: '{"url":"http://localhost:8003/zaken/api/v1/zaakinformatieobjecten/b1ce7c03-1841-444e-a9b0-8e3e4bd2adf5","uuid":"b1ce7c03-1841-444e-a9b0-8e3e4bd2adf5","informatieobject":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/4dbb88e3-b00f-4d4f-8e40-253efefd11b8","zaak":"http://localhost:8003/zaken/api/v1/zaken/4c23542d-2f57-4e3a-922b-896f107d5b10","aardRelatieWeergave":"Hoort + bij, omgekeerd: kent","titel":"","beschrijving":"","registratiedatum":"2024-11-14T16:30:34.973868Z","vernietigingsdatum":null,"status":null}' + headers: + API-version: + - 1.5.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '534' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Location: + - http://localhost:8003/zaken/api/v1/zaakinformatieobjecten/b1ce7c03-1841-444e-a9b0-8e3e4bd2adf5 + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/roltypen?zaaktype=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fzaaktypen%2F1f41885e-23fc-4462-bbc8-80be4ae484dc&omschrijvingGeneriek=initiator + response: + body: + string: '{"count":1,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/roltypen/43e8026c-8abd-4b29-8a4c-ac2a37bc6f5b","zaaktype":"http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","zaaktypeIdentificatie":"ZT-001","omschrijving":"Initiator","omschrijvingGeneriek":"initiator","catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","beginGeldigheid":null,"eindeGeldigheid":null,"beginObject":null,"eindeObject":null}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '524' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: '{"zaak": "http://localhost:8003/zaken/api/v1/zaken/4c23542d-2f57-4e3a-922b-896f107d5b10", + "betrokkeneType": "natuurlijk_persoon", "roltype": "http://localhost:8003/catalogi/api/v1/roltypen/43e8026c-8abd-4b29-8a4c-ac2a37bc6f5b", + "roltoelichting": "inzender formulier", "indicatieMachtiging": "", "betrokkeneIdentificatie": + {"inpBsn": "123456782"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + Content-Length: + - '346' + Content-Type: + - application/json + User-Agent: + - python-requests/2.32.2 + method: POST + uri: http://localhost:8003/zaken/api/v1/rollen + response: + body: + string: '{"url":"http://localhost:8003/zaken/api/v1/rollen/788eab0d-ea88-4f4a-bbbe-220e6b624f03","uuid":"788eab0d-ea88-4f4a-bbbe-220e6b624f03","zaak":"http://localhost:8003/zaken/api/v1/zaken/4c23542d-2f57-4e3a-922b-896f107d5b10","betrokkene":"","betrokkeneType":"natuurlijk_persoon","afwijkendeNaamBetrokkene":"","roltype":"http://localhost:8003/catalogi/api/v1/roltypen/43e8026c-8abd-4b29-8a4c-ac2a37bc6f5b","omschrijving":"Initiator","omschrijvingGeneriek":"initiator","roltoelichting":"inzender + formulier","registratiedatum":"2024-11-14T16:30:35.091478Z","indicatieMachtiging":"","contactpersoonRol":{"emailadres":"","functie":"","telefoonnummer":"","naam":""},"statussen":[],"betrokkeneIdentificatie":{"inpBsn":"123456782","anpIdentificatie":"","inpA_nummer":"","geslachtsnaam":"","voorvoegselGeslachtsnaam":"","voorletters":"","voornamen":"","geslachtsaanduiding":"","geboortedatum":"","verblijfsadres":null,"subVerblijfBuitenland":null}}' + headers: + API-version: + - 1.5.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '935' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Location: + - http://localhost:8003/zaken/api/v1/rollen/788eab0d-ea88-4f4a-bbbe-220e6b624f03 + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/catalogi/api/v1/statustypen?zaaktype=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fzaaktypen%2F1f41885e-23fc-4462-bbc8-80be4ae484dc + response: + body: + string: '{"count":2,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/statustypen/1de05b57-a938-47e4-b808-f129c6406b60","omschrijving":"Afgerond","omschrijvingGeneriek":"","statustekst":"","zaaktype":"http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","zaaktypeIdentificatie":"ZT-001","volgnummer":2,"isEindstatus":true,"informeren":false,"doorlooptijd":null,"toelichting":null,"checklistitemStatustype":[],"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","eigenschappen":[],"zaakobjecttypen":[],"beginGeldigheid":null,"eindeGeldigheid":null,"beginObject":null,"eindeObject":null},{"url":"http://localhost:8003/catalogi/api/v1/statustypen/6443ac1a-04a1-4335-9db2-5f3c998dbb34","omschrijving":"Ontvangen","omschrijvingGeneriek":"","statustekst":"","zaaktype":"http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","zaaktypeIdentificatie":"ZT-001","volgnummer":1,"isEindstatus":false,"informeren":false,"doorlooptijd":null,"toelichting":null,"checklistitemStatustype":[],"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","eigenschappen":[],"zaakobjecttypen":[],"beginGeldigheid":null,"eindeGeldigheid":null,"beginObject":null,"eindeObject":null}]}' + headers: + API-version: + - 1.3.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '1343' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: '{"zaak": "http://localhost:8003/zaken/api/v1/zaken/4c23542d-2f57-4e3a-922b-896f107d5b10", + "statustype": "http://localhost:8003/catalogi/api/v1/statustypen/6443ac1a-04a1-4335-9db2-5f3c998dbb34", + "datumStatusGezet": "2024-11-14T16:30:35.176753+00:00", "statustoelichting": + ""}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + Content-Length: + - '274' + Content-Type: + - application/json + User-Agent: + - python-requests/2.32.2 + method: POST + uri: http://localhost:8003/zaken/api/v1/statussen + response: + body: + string: '{"url":"http://localhost:8003/zaken/api/v1/statussen/466bedd2-4c70-4efd-986d-1defcb4f8ee2","uuid":"466bedd2-4c70-4efd-986d-1defcb4f8ee2","zaak":"http://localhost:8003/zaken/api/v1/zaken/4c23542d-2f57-4e3a-922b-896f107d5b10","statustype":"http://localhost:8003/catalogi/api/v1/statustypen/6443ac1a-04a1-4335-9db2-5f3c998dbb34","datumStatusGezet":"2024-11-14T16:30:35.176753Z","statustoelichting":"","indicatieLaatstGezetteStatus":true,"gezetdoor":null,"zaakinformatieobjecten":[]}' + headers: + API-version: + - 1.5.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '479' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Location: + - http://localhost:8003/zaken/api/v1/statussen/466bedd2-4c70-4efd-986d-1defcb4f8ee2 + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 201 + message: Created +- request: + body: '{"informatieobjecttype": "http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7", + "bronorganisatie": "000000000", "creatiedatum": "2024-11-14", "titel": "myself.mov", + "auteur": "Aanvrager", "taal": "nld", "formaat": "audio/webm", "inhoud": "Y29udGVudA==", + "status": "definitief", "bestandsnaam": "myself.mov", "ontvangstdatum": "2024-06-09", + "beschrijving": "Bijgevoegd document", "indicatieGebruiksrecht": false, "bestandsomvang": + 7}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + Content-Length: + - '477' + Content-Type: + - application/json + User-Agent: + - python-requests/2.32.2 + method: POST + uri: http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten + response: + body: + string: '{"url":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/201a1d86-2d75-455d-adda-38e840f2459d","identificatie":"DOCUMENT-2024-0000000082","bronorganisatie":"000000000","creatiedatum":"2024-11-14","titel":"myself.mov","vertrouwelijkheidaanduiding":"openbaar","auteur":"Aanvrager","status":"definitief","formaat":"audio/webm","taal":"nld","versie":1,"beginRegistratie":"2024-11-14T16:30:35.463187Z","bestandsnaam":"myself.mov","inhoud":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/201a1d86-2d75-455d-adda-38e840f2459d/download?versie=1","bestandsomvang":7,"link":"","beschrijving":"Bijgevoegd + document","ontvangstdatum":"2024-06-09","verzenddatum":null,"indicatieGebruiksrecht":false,"verschijningsvorm":"","ondertekening":{"soort":"","datum":null},"integriteit":{"algoritme":"","waarde":"","datum":null},"informatieobjecttype":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","locked":false,"bestandsdelen":[],"trefwoorden":[],"lock":""}' + headers: + API-version: + - 1.4.2 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '1033' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Location: + - http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/201a1d86-2d75-455d-adda-38e840f2459d + Referrer-Policy: + - same-origin + Vary: + - origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 201 + message: Created +- request: + body: '{"zaak": "http://localhost:8003/zaken/api/v1/zaken/4c23542d-2f57-4e3a-922b-896f107d5b10", + "informatieobject": "http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/201a1d86-2d75-455d-adda-38e840f2459d"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + Content-Length: + - '219' + Content-Type: + - application/json + User-Agent: + - python-requests/2.32.2 + method: POST + uri: http://localhost:8003/zaken/api/v1/zaakinformatieobjecten + response: + body: + string: '{"url":"http://localhost:8003/zaken/api/v1/zaakinformatieobjecten/92ac5f87-9352-4633-b18f-6cb7d1e17466","uuid":"92ac5f87-9352-4633-b18f-6cb7d1e17466","informatieobject":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/201a1d86-2d75-455d-adda-38e840f2459d","zaak":"http://localhost:8003/zaken/api/v1/zaken/4c23542d-2f57-4e3a-922b-896f107d5b10","aardRelatieWeergave":"Hoort + bij, omgekeerd: kent","titel":"","beschrijving":"","registratiedatum":"2024-11-14T16:30:35.575810Z","vernietigingsdatum":null,"status":null}' + headers: + API-version: + - 1.5.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '534' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Location: + - http://localhost:8003/zaken/api/v1/zaakinformatieobjecten/92ac5f87-9352-4633-b18f-6cb7d1e17466 + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.jh3SLHX6EaMfZXVz06Z5UyCeo5XHlrbDsRMtYM4IYwE + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/zaken/api/v1/zaakinformatieobjecten?zaak=http%3A%2F%2Flocalhost%3A8003%2Fzaken%2Fapi%2Fv1%2Fzaken%2F4c23542d-2f57-4e3a-922b-896f107d5b10 + response: + body: + string: '[{"url":"http://localhost:8003/zaken/api/v1/zaakinformatieobjecten/92ac5f87-9352-4633-b18f-6cb7d1e17466","uuid":"92ac5f87-9352-4633-b18f-6cb7d1e17466","informatieobject":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/201a1d86-2d75-455d-adda-38e840f2459d","zaak":"http://localhost:8003/zaken/api/v1/zaken/4c23542d-2f57-4e3a-922b-896f107d5b10","aardRelatieWeergave":"Hoort + bij, omgekeerd: kent","titel":"","beschrijving":"","registratiedatum":"2024-11-14T16:30:35.575810Z","vernietigingsdatum":null,"status":null},{"url":"http://localhost:8003/zaken/api/v1/zaakinformatieobjecten/b1ce7c03-1841-444e-a9b0-8e3e4bd2adf5","uuid":"b1ce7c03-1841-444e-a9b0-8e3e4bd2adf5","informatieobject":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/4dbb88e3-b00f-4d4f-8e40-253efefd11b8","zaak":"http://localhost:8003/zaken/api/v1/zaken/4c23542d-2f57-4e3a-922b-896f107d5b10","aardRelatieWeergave":"Hoort + bij, omgekeerd: kent","titel":"","beschrijving":"","registratiedatum":"2024-11-14T16:30:34.973868Z","vernietigingsdatum":null,"status":null}]' + headers: + API-version: + - 1.5.1 + Allow: + - GET, POST, HEAD, OPTIONS + Content-Length: + - '1071' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + Referrer-Policy: + - same-origin + Vary: + - Accept, origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.kyXv6wR4GfJg9CEPUuHtIiTOv_xavH4ub1UqXTvBTVo + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/201a1d86-2d75-455d-adda-38e840f2459d + response: + body: + string: '{"url":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/201a1d86-2d75-455d-adda-38e840f2459d","identificatie":"DOCUMENT-2024-0000000082","bronorganisatie":"000000000","creatiedatum":"2024-11-14","titel":"myself.mov","vertrouwelijkheidaanduiding":"openbaar","auteur":"Aanvrager","status":"definitief","formaat":"audio/webm","taal":"nld","versie":1,"beginRegistratie":"2024-11-14T16:30:35.463187Z","bestandsnaam":"myself.mov","inhoud":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/201a1d86-2d75-455d-adda-38e840f2459d/download?versie=1","bestandsomvang":7,"link":"","beschrijving":"Bijgevoegd + document","ontvangstdatum":"2024-06-09","verzenddatum":null,"indicatieGebruiksrecht":false,"verschijningsvorm":"","ondertekening":{"soort":"","datum":null},"integriteit":{"algoritme":"","waarde":"","datum":null},"informatieobjecttype":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","locked":false,"bestandsdelen":[],"trefwoorden":[]}' + headers: + API-version: + - 1.4.2 + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Content-Length: + - '1023' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + ETag: + - '"18f94391be52546f515843a381024907"' + Referrer-Policy: + - same-origin + Vary: + - origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTYwMTgzNSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.kyXv6wR4GfJg9CEPUuHtIiTOv_xavH4ub1UqXTvBTVo + Connection: + - keep-alive + User-Agent: + - python-requests/2.32.2 + method: GET + uri: http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/4dbb88e3-b00f-4d4f-8e40-253efefd11b8 + response: + body: + string: '{"url":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/4dbb88e3-b00f-4d4f-8e40-253efefd11b8","identificatie":"DOCUMENT-2024-0000000081","bronorganisatie":"000000000","creatiedatum":"2024-11-14","titel":"Form + 000","vertrouwelijkheidaanduiding":"openbaar","auteur":"Aanvrager","status":"definitief","formaat":"application/pdf","taal":"nld","versie":1,"beginRegistratie":"2024-11-14T16:30:34.885872Z","bestandsnaam":"open-forms-Form + 000.pdf","inhoud":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/4dbb88e3-b00f-4d4f-8e40-253efefd11b8/download?versie=1","bestandsomvang":0,"link":"","beschrijving":"Ingezonden + formulier","ontvangstdatum":null,"verzenddatum":null,"indicatieGebruiksrecht":false,"verschijningsvorm":"","ondertekening":{"soort":"","datum":null},"integriteit":{"algoritme":"","waarde":"","datum":null},"informatieobjecttype":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","locked":false,"bestandsdelen":[],"trefwoorden":[]}' + headers: + API-version: + - 1.4.2 + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Content-Length: + - '1032' + Content-Type: + - application/json + Cross-Origin-Opener-Policy: + - same-origin + ETag: + - '"4c02abbbd4d07c0ec810575aa7e28f96"' + Referrer-Policy: + - same-origin + Vary: + - origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + status: + code: 200 + message: OK +version: 1 diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py index 31bd3ad8f4..fc3901ab08 100644 --- a/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py +++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py @@ -28,7 +28,7 @@ from openforms.utils.tests.vcr import OFVCRMixin from ....constants import RegistrationAttribute -from ..client import get_zaken_client +from ..client import get_documents_client, get_zaken_client from ..plugin import ZGWRegistration from ..typing import RegistrationOptions from .factories import ZGWApiGroupConfigFactory @@ -2637,3 +2637,70 @@ def test_allow_registration_with_unpublished_case_types(self): "http://localhost:8003/catalogi/api/v1/" "zaaktypen/cf903a2f-0acd-4dbf-9c77-6e5e35d794e1", ) + + def test_create_document_with_document_type_description_reference(self): + submission = SubmissionFactory.from_components( + [ + { + "type": "textfield", + "key": "someText", + "label": "Some text", + } + ], + submitted_data={ + "someText": "Foo", + }, + bsn="123456782", + completed=True, + # Pin to a known case & document type version + completed_on=datetime(2024, 6, 9, 15, 30, 0).replace(tzinfo=timezone.utc), + ) + SubmissionFileAttachmentFactory.create(submission_step=submission.steps[0]) + options: RegistrationOptions = { + "zgw_api_group": self.zgw_group, + "catalogue": { + "domain": "TEST", + "rsin": "000000000", + }, + "case_type_identification": "ZT-001", + "document_type_description": "Attachment Informatieobjecttype", + "zaaktype": "", + "informatieobjecttype": "", + "objects_api_group": None, + } + plugin = ZGWRegistration("zgw") + client = get_zaken_client(self.zgw_group) + self.addCleanup(client.close) + pre_registration_result = plugin.pre_register_submission(submission, options) + assert submission.registration_result is not None + submission.registration_result.update(pre_registration_result.data) # type: ignore + submission.save() + + with self.subTest("full registration"): + result = plugin.register_submission(submission, options) + assert result is not None + zaak_url = result["zaak"]["url"] + + with self.subTest("verify related case document"): + zios = client.get( + "zaakinformatieobjecten", params={"zaak": zaak_url} + ).json() + # one for the PDF, one for the attachment + self.assertEqual(len(zios), 2) + + with get_documents_client(self.zgw_group) as documents_client: + for zio in zios: + with self.subTest(zio=zio): + document_data_response = documents_client.get( + zio["informatieobject"] + ) + document_data_response.raise_for_status() + + informatieobjecttype = document_data_response.json()[ + "informatieobjecttype" + ] + self.assertEqual( + informatieobjecttype, + "http://localhost:8003/catalogi/api/v1/" + "informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7", + ) diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_zgw_api_config.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_zgw_api_config.py index 0f37b389e7..f5826f26ae 100644 --- a/src/openforms/registrations/contrib/zgw_apis/tests/test_zgw_api_config.py +++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_zgw_api_config.py @@ -7,7 +7,6 @@ from zgw_consumers.test import generate_oas_component from openforms.plugins.exceptions import InvalidPluginConfiguration -from openforms.registrations.tasks import pre_registration from openforms.submissions.tests.factories import ( SubmissionFactory, SubmissionFileAttachmentFactory, From b66b24476a1576f5d52d2c17f929113e2cdd4e3b Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Wed, 20 Nov 2024 22:11:55 +0100 Subject: [PATCH 15/18] :label: [#4606] Fix type checker errors after rebasing on product feature --- .../registrations/contrib/zgw_apis/tests/test_backend.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py index fc3901ab08..d2a6d19ccc 100644 --- a/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py +++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py @@ -1055,6 +1055,7 @@ def test_submission_with_product(self, m): zgw_form_options: RegistrationOptions = { "zgw_api_group": self.zgw_group, "case_type_identification": "", + "document_type_description": "", "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1", "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1", "product_url": "https://example.com", @@ -1066,6 +1067,8 @@ def test_submission_with_product(self, m): pre_registration_result = plugin.pre_register_submission( submission, zgw_form_options ) + assert submission.registration_result is not None + assert isinstance(pre_registration_result.data, dict) submission.registration_result.update(pre_registration_result.data) submission.save() result = plugin.register_submission(submission, zgw_form_options) @@ -2560,6 +2563,7 @@ def test_create_zaak_with_case_identification_reference_and_product(self): "rsin": "000000000", }, "case_type_identification": "ZT-001", + "document_type_description": "", "zaaktype": "", "informatieobjecttype": ( "http://localhost:8003/catalogi/api/v1/" @@ -2667,6 +2671,7 @@ def test_create_document_with_document_type_description_reference(self): "zaaktype": "", "informatieobjecttype": "", "objects_api_group": None, + "product_url": "", } plugin = ZGWRegistration("zgw") client = get_zaken_client(self.zgw_group) From eaff396388bb0466b7518894f0f1cfed2ead8cdd Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Wed, 20 Nov 2024 22:15:14 +0100 Subject: [PATCH 16/18] :art: Cleanup leftovers from product feature * Added missing prop type for new form field * Extended list of field names contained in optional settings fieldset --- .../registrations/zgw/OptionalOptionsFieldset.js | 7 ++++++- .../admin/form_design/registrations/zgw/ZGWOptionsForm.js | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/OptionalOptionsFieldset.js b/src/openforms/js/components/admin/form_design/registrations/zgw/OptionalOptionsFieldset.js index 622c8ded67..708d541ae5 100644 --- a/src/openforms/js/components/admin/form_design/registrations/zgw/OptionalOptionsFieldset.js +++ b/src/openforms/js/components/admin/form_design/registrations/zgw/OptionalOptionsFieldset.js @@ -19,7 +19,12 @@ const OptionalOptionsFieldset = ({confidentialityLevelChoices}) => { defaultMessage="Optional ZGW configuration" /> } - fieldNames={['organisatieRsin']} + fieldNames={[ + 'organisatieRsin', + 'zaakVertrouwelijkheidaanduiding', + 'medewerkerRoltype', + 'productUrl', + ]} >
Date: Mon, 25 Nov 2024 10:20:40 +0100 Subject: [PATCH 17/18] :ok_hand: [#4606] PR feedback - update language Consistenly use 'document types' rather than informatieobjecttypen, as the URLs themselves have been updated and new code uses this language. --- src/openapi.yaml | 7 +++---- src/openforms/contrib/zgw/api/filters.py | 2 +- src/openforms/registrations/contrib/zgw_apis/api/views.py | 4 +--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/openapi.yaml b/src/openapi.yaml index 8a29313a48..a03b58144e 100644 --- a/src/openapi.yaml +++ b/src/openapi.yaml @@ -3520,7 +3520,7 @@ paths: format: uri default: '' minLength: 1 - description: Filter informatieobjecttypen against this catalogue URL. + description: Filter document types against this catalogue URL. - in: query name: objects_api_group schema: @@ -4205,8 +4205,7 @@ paths: Each InformatieObjectType is uniquely identified by its 'omschrijving', 'catalogus', and beginning and end date. If multiple same InformatieObjectTypen exist for different dates, only one entry is returned. - summary: List the available InformatieObjectTypen from the provided ZGW API - group + summary: List the available document types from the provided ZGW API group parameters: - in: query name: case_type_identification @@ -4225,7 +4224,7 @@ paths: format: uri default: '' minLength: 1 - description: Filter informatieobjecttypen against this catalogue URL. + description: Filter document types against this catalogue URL. - in: query name: zgw_api_group schema: diff --git a/src/openforms/contrib/zgw/api/filters.py b/src/openforms/contrib/zgw/api/filters.py index bf7fe5cd48..6d2b5a8fa8 100644 --- a/src/openforms/contrib/zgw/api/filters.py +++ b/src/openforms/contrib/zgw/api/filters.py @@ -14,7 +14,7 @@ def get_ztc_client(self) -> CatalogiClient: class DocumentTypesFilter(serializers.Serializer): catalogue_url = serializers.URLField( label=_("catalogue URL"), - help_text=_("Filter informatieobjecttypen against this catalogue URL."), + help_text=_("Filter document types against this catalogue URL."), required=False, default="", ) diff --git a/src/openforms/registrations/contrib/zgw_apis/api/views.py b/src/openforms/registrations/contrib/zgw_apis/api/views.py index 5e3101c66e..21a64f3510 100644 --- a/src/openforms/registrations/contrib/zgw_apis/api/views.py +++ b/src/openforms/registrations/contrib/zgw_apis/api/views.py @@ -82,9 +82,7 @@ def get_objects(self): @extend_schema_view( get=extend_schema( - summary=_( - "List the available InformatieObjectTypen from the provided ZGW API group" - ), + summary=_("List the available document types from the provided ZGW API group"), parameters=[ListDocumentTypesQueryParamsSerializer], ), ) From fe771dabf3523f074dbb281094aeeca34acf91a0 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Mon, 25 Nov 2024 10:22:05 +0100 Subject: [PATCH 18/18] :recycle: [#4606] Rename URL name to get list of document types --- src/openforms/contrib/objects_api/api/urls.py | 2 +- .../forms/tests/e2e_tests/test_registration_backend_conf.py | 4 ++-- .../contrib/objects_api/tests/test_api_endpoints.py | 2 +- src/openforms/registrations/contrib/zgw_apis/api/urls.py | 2 +- .../contrib/zgw_apis/tests/test_api_endpoints.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/openforms/contrib/objects_api/api/urls.py b/src/openforms/contrib/objects_api/api/urls.py index b5941e846a..8881f5eb6b 100644 --- a/src/openforms/contrib/objects_api/api/urls.py +++ b/src/openforms/contrib/objects_api/api/urls.py @@ -28,6 +28,6 @@ path( "document-types", DocumentTypesListView.as_view(), - name="iotypen-list", + name="document-type-list", ), ] diff --git a/src/openforms/forms/tests/e2e_tests/test_registration_backend_conf.py b/src/openforms/forms/tests/e2e_tests/test_registration_backend_conf.py index 65985d7573..3b9749588c 100644 --- a/src/openforms/forms/tests/e2e_tests/test_registration_backend_conf.py +++ b/src/openforms/forms/tests/e2e_tests/test_registration_backend_conf.py @@ -101,7 +101,7 @@ def collect_requests(request): log_flaky() return - if match.view_name == "api:zgw_apis:iotypen-list": + if match.view_name == "api:zgw_apis:document-type-list": requests_to_endpoint.append(request) async with browser_page() as page: @@ -233,7 +233,7 @@ def collect_requests(request): log_flaky() return - if match.view_name == "api:objects_api:iotypen-list": + if match.view_name == "api:objects_api:document-type-list": requests_to_endpoint.append(request) async with browser_page() as page: diff --git a/src/openforms/registrations/contrib/objects_api/tests/test_api_endpoints.py b/src/openforms/registrations/contrib/objects_api/tests/test_api_endpoints.py index aaccf48dd8..141524a1b1 100644 --- a/src/openforms/registrations/contrib/objects_api/tests/test_api_endpoints.py +++ b/src/openforms/registrations/contrib/objects_api/tests/test_api_endpoints.py @@ -279,7 +279,7 @@ def test_list_catalogus(self): class GetInformatieObjecttypesViewTests(OFVCRMixin, APITestCase): VCR_TEST_FILES = TEST_FILES - endpoint = reverse_lazy("api:objects_api:iotypen-list") + endpoint = reverse_lazy("api:objects_api:document-type-list") @classmethod def setUpTestData(cls): diff --git a/src/openforms/registrations/contrib/zgw_apis/api/urls.py b/src/openforms/registrations/contrib/zgw_apis/api/urls.py index d4876cb354..8dce4caece 100644 --- a/src/openforms/registrations/contrib/zgw_apis/api/urls.py +++ b/src/openforms/registrations/contrib/zgw_apis/api/urls.py @@ -12,6 +12,6 @@ urlpatterns = [ path("catalogues", CatalogueListView.as_view(), name="catalogue-list"), path("case-types", CaseTypesListView.as_view(), name="case-type-list"), - path("document-types", DocumentTypesListView.as_view(), name="iotypen-list"), + path("document-types", DocumentTypesListView.as_view(), name="document-type-list"), path("products", ProductsListView.as_view(), name="product-list"), ] diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_api_endpoints.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_api_endpoints.py index 271aa463f2..36e2ef8438 100644 --- a/src/openforms/registrations/contrib/zgw_apis/tests/test_api_endpoints.py +++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_api_endpoints.py @@ -190,7 +190,7 @@ def test_drafts_included_with_feature_flag_on(self): class GetInformatieObjecttypesViewTests(OFVCRMixin, APITestCase): VCR_TEST_FILES = TEST_FILES - endpoint = reverse_lazy("api:zgw_apis:iotypen-list") + endpoint = reverse_lazy("api:zgw_apis:document-type-list") @classmethod def setUpTestData(cls):