From 3bc73bcf9b521701742e9684bff316727bf457e5 Mon Sep 17 00:00:00 2001 From: SilviaAmAm Date: Fri, 8 Dec 2023 11:10:49 +0100 Subject: [PATCH 1/3] :adhesive_bandage: [#3649] Add bestandsomvang field --- src/openforms/contrib/zgw/clients/documenten.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/openforms/contrib/zgw/clients/documenten.py b/src/openforms/contrib/zgw/clients/documenten.py index 3a2804a88a..41453f7356 100644 --- a/src/openforms/contrib/zgw/clients/documenten.py +++ b/src/openforms/contrib/zgw/clients/documenten.py @@ -32,7 +32,8 @@ def create_document( ): assert author, "author must be a non-empty string" today = get_today() - base64_body = b64encode(content.read()).decode() + file_content = content.read() + base64_body = b64encode(file_content).decode() data = { "informatieobjecttype": informatieobjecttype, "bronorganisatie": bronorganisatie, @@ -46,6 +47,9 @@ def create_document( "bestandsnaam": filename, "beschrijving": description, "indicatieGebruiksrecht": False, + "bestandsomvang": ( + content.size if hasattr(content, "size") else len(file_content) + ), } if vertrouwelijkheidaanduiding: From 92088703de8cc049ce420a6346628406a18f0918 Mon Sep 17 00:00:00 2001 From: SilviaAmAm Date: Fri, 8 Dec 2023 15:00:31 +0100 Subject: [PATCH 2/3] :white_check_mark: [#3649] Add test --- .../contrib/zgw_apis/tests/test_backend.py | 51 +++++++++++++++++++ 1 file changed, 51 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 d79f108cd9..ac27552757 100644 --- a/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py +++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py @@ -1,3 +1,4 @@ +import json from decimal import Decimal from django.test import TestCase, override_settings, tag @@ -1392,6 +1393,56 @@ def test_zgw_backend_has_reference_after_pre_submission(self, m): submission.refresh_from_db() self.assertEqual(submission.public_registration_reference, "ZAAK-OF-TEST") + @tag("gh-3649") + def test_document_size_argument_present(self, m): + submission = SubmissionFactory.from_components( + [ + { + "key": "field1", + "type": "file", + }, + ], + ) + zgw_form_options = dict( + zgw_api_group=self.zgw_group, + zaaktype="https://catalogi.nl/api/v1/zaaktypen/1", + informatieobjecttype="https://catalogi.nl/api/v1/informatieobjecttypen/1", + organisatie_rsin="000000000", + zaak_vertrouwelijkheidaanduiding="openbaar", + ) + SubmissionFileAttachmentFactory.create( + submission_step=SubmissionStep.objects.first(), + content__data=b"content", + file_name="attachment1.txt", + form_key="field1", + _component_configuration_path="components.0", + ) + + self.install_mocks(m) + + plugin = ZGWRegistration("zgw") + plugin.pre_register_submission(submission, zgw_form_options) + plugin.register_submission(submission, zgw_form_options) + + ( + create_zaak, + create_pdf_document, + relate_pdf_document, + get_roltypen, + create_rol, + get_statustypen, + create_status, + create_attachment1_document, + relate_attachment1_document, + ) = m.request_history + + self.assertIn("bestandsomvang", json.loads(create_pdf_document.body)) + + attachment_data = json.loads(create_attachment1_document.body) + + self.assertIn("bestandsomvang", attachment_data) + self.assertEqual(attachment_data["bestandsomvang"], 7) + @tag("gh-1183") @temp_private_root() From ac3feec1386049acc8358017d3834c8ed806f92d Mon Sep 17 00:00:00 2001 From: SilviaAmAm Date: Fri, 8 Dec 2023 15:09:05 +0100 Subject: [PATCH 3/3] :memo: [#3649] Document compatibility with Documenten APIs --- docs/configuration/registration/zgw.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/configuration/registration/zgw.rst b/docs/configuration/registration/zgw.rst index 3143a75795..bf57251d25 100644 --- a/docs/configuration/registration/zgw.rst +++ b/docs/configuration/registration/zgw.rst @@ -35,7 +35,7 @@ OAS URL to the OAS. Client ID Client ID for the JWT-token. Secret Secret for the JWT-token. **Documenten API** -API root URL Root URL for the Documenten API that Open Forms can access. +API root URL Root URL for the Documenten API (version 1.1+) that Open Forms can access. OAS URL to the OAS. Client ID Client ID for the JWT-token. Secret Secret for the JWT-token. @@ -133,6 +133,6 @@ Technical API Supported versions ================ =================== Zaken API 1.0 -Documenten API 1.0 +Documenten API 1.1+ Catalogi API 1.0 ================ ===================