From 6439ade752157bd5274cf3a288e0439477db3d57 Mon Sep 17 00:00:00 2001 From: Dan Jacob Date: Tue, 12 Dec 2023 12:56:31 +0200 Subject: [PATCH 1/2] Update Traficom copyright message Refs: PV-740 --- locale/fi/LC_MESSAGES/django.po | 4 ++-- locale/sv/LC_MESSAGES/django.po | 4 ++-- parking_permits/exporters.py | 4 ++-- parking_permits/talpa/order.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/locale/fi/LC_MESSAGES/django.po b/locale/fi/LC_MESSAGES/django.po index ec32c3fc..d56bca33 100644 --- a/locale/fi/LC_MESSAGES/django.po +++ b/locale/fi/LC_MESSAGES/django.po @@ -318,8 +318,8 @@ msgstr "Helsingin kaupunki" msgid "Personal data - Digital and population data services agency" msgstr "Henkilötiedot - Digi- ja väestötietovirasto" -msgid "Vehicle information - Transport register, Traficom" -msgstr "Ajoneuvon tiedot - Liikenneasioidenrekisteri, Traficom" +msgid "Source: Transport register, Traficom" +msgstr "Lähde: Liikenneasioidenrekisteri, Traficom" msgid "Permit ID" msgstr "Tunniste" diff --git a/locale/sv/LC_MESSAGES/django.po b/locale/sv/LC_MESSAGES/django.po index 003607ad..95745388 100644 --- a/locale/sv/LC_MESSAGES/django.po +++ b/locale/sv/LC_MESSAGES/django.po @@ -313,8 +313,8 @@ msgstr "Helsingfors stad" msgid "Personal data - Digital and population data services agency" msgstr "Personuppgifter - Digital- och befolkningsdatatjänstbyrå" -msgid "Vehicle information - Transport register, Traficom" -msgstr "Fordonsuppgifter - Trafik- och transportregistret, Traficom" +msgid "Source: Transport register, Traficom" +msgstr "Källä: Trafik- och transportregistret, Traficom" msgid "Permit ID" msgstr "Permit ID" diff --git a/parking_permits/exporters.py b/parking_permits/exporters.py index 663a6314..a5cae9ee 100644 --- a/parking_permits/exporters.py +++ b/parking_permits/exporters.py @@ -198,7 +198,7 @@ def get_metadata(self): "© " + _("City of Helsinki") + ", ", _("Personal data - Digital and population data services agency") + ", ", - _("Vehicle information - Transport register, Traficom") + _("Source: Transport register, Traficom") + " " + str(CURRENT_YEAR), } @@ -235,7 +235,7 @@ def footer(self): self.cell( 0, 5, - _("Vehicle information - Transport register, Traficom") + _("Source: Transport register, Traficom") + " " + str(CURRENT_YEAR), 0, diff --git a/parking_permits/talpa/order.py b/parking_permits/talpa/order.py index 0a2c62d1..47092c5d 100644 --- a/parking_permits/talpa/order.py +++ b/parking_permits/talpa/order.py @@ -99,7 +99,7 @@ def _append_detail_meta(cls, item, permit): { "key": "copyright", "label": "", - "value": f'© {_("Vehicle information - Transport register, Traficom")}', + "value": _("Source: Transport register, Traficom"), "visibleInCheckout": True, "ordinal": 5, }, From 36a5a2989d7994b88fed3f4b71c07ea15f2e9c17 Mon Sep 17 00:00:00 2001 From: Dan Jacob Date: Tue, 12 Dec 2023 13:46:12 +0200 Subject: [PATCH 2/2] Add Traficom attribution to Traficom error messages Refs: PV-740 --- parking_permits/error_formatter.py | 29 +++++++++++++++++++---------- parking_permits/exporters.py | 8 ++------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/parking_permits/error_formatter.py b/parking_permits/error_formatter.py index a2f97c2f..c32d3da0 100644 --- a/parking_permits/error_formatter.py +++ b/parking_permits/error_formatter.py @@ -1,16 +1,25 @@ from ariadne import format_error from django.core.exceptions import PermissionDenied -from django.utils.translation import gettext_lazy as _ +from django.utils.translation import gettext as _ -from parking_permits.exceptions import ParkingPermitBaseException +from parking_permits.exceptions import ( + ParkingPermitBaseException, + TraficomFetchVehicleError, +) def error_formatter(error, debug): - formatted = format_error(error, debug) - if isinstance(error.original_error, ParkingPermitBaseException): - formatted["message"] = str(error.original_error) - elif isinstance(error.original_error, PermissionDenied): - formatted["message"] = _("Forbidden") - else: - formatted["message"] = _("Internal Server Error") - return formatted + return { + **format_error(error, debug), + "message": get_error_message(error.original_error), + } + + +def get_error_message(exc): + if isinstance(exc, TraficomFetchVehicleError): + return f"{exc}\n{_('Source: Transport register, Traficom')}" + if isinstance(exc, ParkingPermitBaseException): + return str(exc) + if isinstance(exc, PermissionDenied): + return _("Forbidden") + return _("Internal Server Error") diff --git a/parking_permits/exporters.py b/parking_permits/exporters.py index a5cae9ee..a789fc13 100644 --- a/parking_permits/exporters.py +++ b/parking_permits/exporters.py @@ -198,9 +198,7 @@ def get_metadata(self): "© " + _("City of Helsinki") + ", ", _("Personal data - Digital and population data services agency") + ", ", - _("Source: Transport register, Traficom") - + " " - + str(CURRENT_YEAR), + _("Source: Transport register, Traficom") + " " + str(CURRENT_YEAR), } } } @@ -235,9 +233,7 @@ def footer(self): self.cell( 0, 5, - _("Source: Transport register, Traficom") - + " " - + str(CURRENT_YEAR), + _("Source: Transport register, Traficom") + " " + str(CURRENT_YEAR), 0, 1, )