From f2b94b9ea5166c7b4c5a7aa2d60659a547ebacdc Mon Sep 17 00:00:00 2001 From: Roman Kysil Date: Wed, 27 Nov 2024 10:43:41 +0100 Subject: [PATCH] Additional try/except --- .../prenotazioni/browser/bookings_export.py | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/redturtle/prenotazioni/browser/bookings_export.py b/src/redturtle/prenotazioni/browser/bookings_export.py index e0e924b8..ed04d24e 100644 --- a/src/redturtle/prenotazioni/browser/bookings_export.py +++ b/src/redturtle/prenotazioni/browser/bookings_export.py @@ -222,14 +222,28 @@ def __call__(self): ) if booking_creation_from: - self.booking_creation_from = datetime.datetime.fromisoformat( - booking_creation_from - ) + try: + self.booking_creation_from = datetime.datetime.fromisoformat( + booking_creation_from + ) + except ValueError: + raise BadRequest( + api.portal_translate( + _("Badly composed `booking_creation_from` value") + ) + ) if booking_creation_to: - self.booking_creation_to = datetime.datetime.fromisoformat( - booking_creation_to - ) + try: + self.booking_creation_to = datetime.datetime.fromisoformat( + booking_creation_to + ) + except: + raise BadRequest( + api.portal_translate( + _("Badly composed `booking_creation_to` value") + ) + ) self.setHeader( "Content-Disposition", "attachment;filename=%s" % self.csv_filename