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

[#1174] Fixed number and currency localisation in get_printable_data() #1185

Merged
merged 1 commit into from
Jan 13, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/openforms/submissions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from django.urls import resolve
from django.utils import timezone
from django.utils.dateparse import parse_date, parse_time
from django.utils.formats import localize
from django.utils.translation import gettext, gettext_lazy as _

from celery.result import AsyncResult
Expand Down Expand Up @@ -621,6 +622,12 @@ def get_printable_data(
]
printable_data[label] = ", ".join(selected_labels)

elif info["type"] == "number":
printable_data[label] = localize(info["value"])

elif info["type"] == "currency":
printable_data[label] = localize(info["value"])

elif type(info["value"]) is dict:
printable_value = info["value"]
if "name" in printable_value:
Expand Down
23 changes: 23 additions & 0 deletions src/openforms/submissions/tests/test_submission_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,23 @@ def test_submission_printable_data(self):
"showTimes": True,
},
},
{
"key": "number1",
"type": "number",
"label": "Test number 1",
"decimalLimit": 0,
},
{
"key": "number2",
"type": "number",
"label": "Test number 2",
"decimalLimit": 2,
},
{
"key": "currency",
"type": "currency",
"label": "Test currency",
},
]
}
)
Expand All @@ -181,6 +198,9 @@ def test_submission_printable_data(self):
"time0": "17:30:00",
"date3": "2021-12-24",
"time1": "2021-12-24T08:10:00+01:00",
"number1": 1,
"number2": 1.23,
"currency": 1.23,
},
submission=submission,
form_step=form_step,
Expand All @@ -196,6 +216,9 @@ def test_submission_printable_data(self):
("Test time 1", "17:30"),
("Afspraakdatum", "24 december 2021"),
("Afspraaktijdstip", "08:10"),
("Test number 1", "1"),
("Test number 2", "1,23"),
("Test currency", "1,23"),
]
for label, value in values:
with self.subTest(label):
Expand Down