diff --git a/src/openforms/submissions/report.py b/src/openforms/submissions/report.py index 6d1fe18fb3..5eb30e722b 100644 --- a/src/openforms/submissions/report.py +++ b/src/openforms/submissions/report.py @@ -59,6 +59,12 @@ def co_signer(self) -> str: if not (co_sign_data := self.submission.co_sign_data): return "" + # XXX this is something present in cosign v2 but not v1, which happens after the + # PDF is generated. Generating the PDF again after it's cosigned otherwise + # crashes. + if "cosign_date" in co_sign_data: + return "" + representation = co_sign_data.get("representation") or "" identifier = co_sign_data["identifier"] co_sign_auth_attribute = co_sign_data["co_sign_auth_attribute"] diff --git a/src/openforms/submissions/tests/test_tasks_pdf.py b/src/openforms/submissions/tests/test_tasks_pdf.py index d641affe0f..7dc8ab0519 100644 --- a/src/openforms/submissions/tests/test_tasks_pdf.py +++ b/src/openforms/submissions/tests/test_tasks_pdf.py @@ -559,3 +559,19 @@ def test_incomplete_cosign_data_missing_representation(self): ), ) self.assertIn(identifier, rendered) + + def test_cosign_v2_data(self): + report = SubmissionReportFactory.create( + content="", + submission__completed=True, + submission__co_sign_data={ + "plugin": "digid", + "attribute": "bsn", + "value": "123456782", + "cosign_date": "2024-01-01T17:00:00Z", + }, + ) + + html: str = report.generate_submission_report_pdf() + + self.assertNotEqual(html, "")