Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#4005] Filter submission reports #4095

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading