Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mhieta committed Dec 13, 2023
2 parents fa9021a + 36a5a29 commit f528b7b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 21 deletions.
4 changes: 2 additions & 2 deletions locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions locale/sv/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
29 changes: 19 additions & 10 deletions parking_permits/error_formatter.py
Original file line number Diff line number Diff line change
@@ -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")
8 changes: 2 additions & 6 deletions parking_permits/exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ def get_metadata(self):
"© " + _("City of Helsinki") + ", ",
_("Personal data - Digital and population data services agency")
+ ", ",
_("Vehicle information - Transport register, Traficom")
+ " "
+ str(CURRENT_YEAR),
_("Source: Transport register, Traficom") + " " + str(CURRENT_YEAR),
}
}
}
Expand Down Expand Up @@ -235,9 +233,7 @@ def footer(self):
self.cell(
0,
5,
_("Vehicle information - Transport register, Traficom")
+ " "
+ str(CURRENT_YEAR),
_("Source: Transport register, Traficom") + " " + str(CURRENT_YEAR),
0,
1,
)
Expand Down
2 changes: 1 addition & 1 deletion parking_permits/talpa/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down

0 comments on commit f528b7b

Please sign in to comment.