Skip to content

Commit

Permalink
Merge pull request #4139 from open-formulieren/feature/4080-timestamp
Browse files Browse the repository at this point in the history
[#4080] Add timestamp to PDF report
  • Loading branch information
sergei-maertens authored Apr 9, 2024
2 parents f9aee71 + 9c59ba0 commit cb43eea
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% get_solo 'config.GlobalConfiguration' as config %}
{% get_theme as theme %}
{% get_current_language as LANG %}
{% now "DATETIME_FORMAT" as now_str %}
<html lang="{{ LANG }}" class="{{ theme.get_classname }}">
<head>
<meta charset="utf-8">
Expand Down Expand Up @@ -36,6 +37,9 @@ <h1 class="title">{{ report.form.name }}</h1>
<p>{% blocktrans with submission_date=report.submission.completed_on trimmed %}
Submitted on: {{ submission_date }}
{% endblocktrans %}</p>
<p>{% blocktrans trimmed %}
Report created on: {{ now_str }}
{% endblocktrans %}</p>
<p>{% blocktrans with ref=report.submission.public_registration_reference trimmed %}
Your reference is: {{ ref }}
{% endblocktrans %}</p>
Expand Down
24 changes: 23 additions & 1 deletion src/openforms/submissions/tests/test_tasks_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _

from freezegun import freeze_time
from privates.test import temp_private_root
from pyquery import PyQuery as pq
from testfixtures import LogCapture
Expand Down Expand Up @@ -236,10 +237,31 @@ def test_public_reference_included(self):
html = submission.report.generate_submission_report_pdf()

doc = pq(html)
reference_node = doc(".metadata").children()[1]
reference_node = doc(".metadata").children()[2]

self.assertEqual(reference_node.text, "Your reference is: OF-12345")

@freeze_time("2024-01-01")
@override_settings(LANGUAGE_CODE="en")
def test_timestamp_included(self):
submission = SubmissionFactory.from_components(
[
{
"key": "input",
"label": "Input",
"type": "textfield",
},
],
public_registration_reference="OF-12345",
)

html = submission.report.generate_submission_report_pdf()

doc = pq(html)
reference_node = doc(".metadata").children()[1]

self.assertEqual(reference_node.text, "Report created on: Jan. 1, 2024, 1 a.m.")


@temp_private_root()
class SubmissionReportCoSignTests(TestCase):
Expand Down

0 comments on commit cb43eea

Please sign in to comment.