From b140dc5f899be61bca36b56914d0f72320d88a17 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 13 Mar 2023 17:04:57 +0100 Subject: [PATCH] fix without logo --- ereuse_devicehub/forms.py | 3 +++ ereuse_devicehub/inventory/forms.py | 3 +++ ereuse_devicehub/views.py | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/forms.py b/ereuse_devicehub/forms.py index 4980b41e..ef383588 100644 --- a/ereuse_devicehub/forms.py +++ b/ereuse_devicehub/forms.py @@ -141,6 +141,9 @@ class SanitizationEntityForm(FlaskForm): if not is_valid: return False + if not self.logo.data: + return True + extensions = ["jpg", "jpeg", "png", "gif", "svg"] if self.logo.data.lower().split(".")[-1] not in extensions: txt = "Error in Url field - accepted only .PNG, .JPG and .GIF. extensions" diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index dff4e87e..ffb8d13c 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -1565,6 +1565,9 @@ class CustomerDetailsForm(FlaskForm): if not is_valid: return is_valid + if not self.logo.data: + return True + extensions = ["jpg", "jpeg", "png", "gif", "svg"] if self.logo.data.lower().split(".")[-1] not in extensions: txt = "Error in Url field - accepted only .PNG, .JPG and .GIF. extensions" diff --git a/ereuse_devicehub/views.py b/ereuse_devicehub/views.py index 65cb4d3a..8f9a5e1d 100644 --- a/ereuse_devicehub/views.py +++ b/ereuse_devicehub/views.py @@ -145,7 +145,8 @@ class SanitizationEntityView(View): messages.error('Error modifying Sanitization data!') if form.errors: for k in form.errors.keys(): - txt = "{}: {}".format(k, form.errors[k]) + errors = ", ".join(form.errors[k]) + txt = "{}: {}".format(k, errors) messages.error(txt) return flask.redirect(flask.url_for('core.user-profile'))