Skip to content

Commit

Permalink
Merge pull request #4095 from open-formulieren/feature/4005-search-su…
Browse files Browse the repository at this point in the history
…bmission-reports

[#4005] Filter submission reports
  • Loading branch information
sergei-maertens authored Apr 4, 2024
2 parents 3864870 + a4fe8d0 commit 77bb227
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/openforms/submissions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,11 @@ def retry_processing_submissions(self, request, queryset):
class SubmissionReportAdmin(PrivateMediaMixin, admin.ModelAdmin):
list_display = ("title",)
list_filter = ("title",)
search_fields = ("title",)
search_fields = (
"title",
"submission__uuid",
"submission__public_registration_reference",
)
raw_id_fields = ("submission",)

private_media_fields = ("content",)
Expand Down
6 changes: 5 additions & 1 deletion src/openforms/submissions/tasks/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def generate_submission_report(task, submission_id: int) -> None:
submission_report = submission.report
except SubmissionReport.DoesNotExist:
submission_report = SubmissionReport.objects.create(
title=_("%(title)s: Submission report") % {"title": submission.form.name},
title=_("%(title)s: Submission report (%(reference)s)")
% {
"title": submission.form.name,
"reference": submission.public_registration_reference,
},
submission=submission,
task_id=task.request.id,
)
Expand Down
9 changes: 7 additions & 2 deletions src/openforms/submissions/tests/test_tasks_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@
class SubmissionReportGenerationTests(TestCase):
def test_submission_report_metadata(self):
submission = SubmissionFactory.create(
completed=True, form__name="Test Form", form__slug="test-form"
completed=True,
form__name="Test Form",
form__slug="test-form",
public_registration_reference="OF-TRALALA",
)

generate_submission_report.request.id = "some-id"
generate_submission_report.run(submission.id)

report = SubmissionReport.objects.get()
self.assertEqual(
_("%(title)s: Submission report") % {"title": "Test Form"}, report.title
_("%(title)s: Submission report (%(reference)s)")
% {"title": "Test Form", "reference": "OF-TRALALA"},
report.title,
)
self.assertEqual(submission, report.submission)
self.assertTrue(report.content.name.endswith("test-form.pdf"))
Expand Down

0 comments on commit 77bb227

Please sign in to comment.