Browse Source

feat(reservations): message d'erreur plus clair en cas d'erreur

master
Vincent Adolphe 2 months ago
parent
commit
c47a2dde5f
  1. 14
      betg/apps/evenements/views.py

14
betg/apps/evenements/views.py

@ -298,19 +298,23 @@ class ReservationProcess(ReservationActionMixin, UserPassesTestMixin):
# .save() trigger .errors that trigger form.clean()
# and model.full_clean()
# form.clean() and model.full_clean() can raise
# django..ValidationError
# django.ValidationError
# but when trigger by .save()/.error it raise a ValueError instead
# https://docs.djangoproject.com/en/1.11/topics/forms/modelforms/
# #the-save-method
except:
logger.error("user[%s]" % (self.request.user))
logger.error("POST[%s]" % (self.request.POST))
logger.exception("form.errors = %s", form.errors.as_data())
logger.error(
"user[%s] POST[%s]" % (self.request.user, self.request.POST)
)
messages.error(
self.request,
(
"Impossible de traiter la réservation {0}, une erreur "
"inattendue s'est produite.".format(self.reservation.pk)
"Impossible de traiter la réservation {0}: "
"{1}".format(
str(self.reservation),
', '.join(form.errors.get('__all__', [])),
)
),
)
else:

Loading…
Cancel
Save
Map all the world