diff --git a/src/stuf/stuf_zds/client.py b/src/stuf/stuf_zds/client.py index c69c8ff402..6833bf1ac0 100644 --- a/src/stuf/stuf_zds/client.py +++ b/src/stuf/stuf_zds/client.py @@ -374,7 +374,8 @@ def create_zaak_attachment( doc_id=doc_id, document=submission_attachment, doc_data={ - "titel": "bijlage", + "titel": submission_attachment.titel + or submission_attachment.get_display_name(), "bestandsnaam": submission_attachment.get_display_name(), "formaat": submission_attachment.content_type, "beschrijving": "Bijgevoegd document", diff --git a/src/stuf/stuf_zds/tests/test_backend.py b/src/stuf/stuf_zds/tests/test_backend.py index b2e0abd0b7..789d4d7280 100644 --- a/src/stuf/stuf_zds/tests/test_backend.py +++ b/src/stuf/stuf_zds/tests/test_backend.py @@ -8,7 +8,9 @@ from openforms.logging.models import TimelineLogProxy from openforms.registrations.exceptions import RegistrationFailed +from openforms.submissions.models import SubmissionStep from openforms.submissions.tests.factories import ( + SubmissionFactory, SubmissionFileAttachmentFactory, SubmissionReportFactory, ) @@ -453,6 +455,62 @@ def test_create_zaak_attachment(self, m): 1, ) + def test_create_zaak_attachment_with_custom_title(self, m): + client = StufZDSClient(self.service, self.options) + m.post( + self.service.soap_service.url, + content=load_mock("voegZaakdocumentToe.xml"), + additional_matcher=match_text("edcLk01"), + ) + + SubmissionFactory.from_components( + [ + { + "key": "field1", + "type": "file", + "registration": { + "titel": "a custom title", + }, + }, + ] + ) + + submission_attachment = SubmissionFileAttachmentFactory.create( + submission_step=SubmissionStep.objects.first(), + file_name="my-attachment.doc", + content_type="application/msword", + _component_configuration_path="components.0", + ) + + client.create_zaak_attachment( + zaak_id="foo", doc_id="bar", submission_attachment=submission_attachment + ) + request = m.request_history[0] + self.assertEqual( + request.headers["SOAPAction"], + "http://www.egem.nl/StUF/sector/zkn/0310/voegZaakdocumentToe_Lk01", + ) + + xml_doc = xml_from_request_history(m, 0) + self.assertSoapXMLCommon(xml_doc) + self.assertXPathExists(xml_doc, "//zkn:edcLk01") + self.assertStuurgegevens(xml_doc) + self.assertXPathEqualDict( + xml_doc, + { + "//zkn:stuurgegevens/stuf:berichtcode": "Lk01", + "//zkn:stuurgegevens/stuf:entiteittype": "EDC", + "//zkn:object/zkn:identificatie": "bar", + "//zkn:object/zkn:dct.omschrijving": "dt-omschrijving", + "//zkn:object/zkn:inhoud/@stuf:bestandsnaam": "my-attachment.doc", + "//zkn:object/zkn:inhoud/@xmime:contentType": "application/msword", + "//zkn:object/zkn:formaat": "application/msword", + "//zkn:object/zkn:isRelevantVoor/zkn:gerelateerde/zkn:identificatie": "foo", + "//zkn:object/zkn:isRelevantVoor/zkn:gerelateerde/zkn:omschrijving": "my-form", + "//zkn:titel": "a custom title", + }, + ) + def test_client_wraps_network_error(self, m): client = StufZDSClient(self.service, self.options) m.post(self.service.soap_service.url, exc=RequestException)