feedback when there are one error in sanitization form
This commit is contained in:
parent
93d6502a66
commit
6d722bb19f
|
@ -141,6 +141,12 @@ class SanitizationEntityForm(FlaskForm):
|
|||
if not is_valid:
|
||||
return False
|
||||
|
||||
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"
|
||||
self.logo.errors = [txt]
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def save(self, commit=True):
|
||||
|
|
|
@ -1561,7 +1561,17 @@ class CustomerDetailsForm(FlaskForm):
|
|||
|
||||
def validate(self, extra_validators=None):
|
||||
is_valid = super().validate(extra_validators)
|
||||
return is_valid
|
||||
|
||||
if not is_valid:
|
||||
return is_valid
|
||||
|
||||
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"
|
||||
self.logo.errors = [txt]
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def save(self, commit=True):
|
||||
self.populate_obj(self._obj)
|
||||
|
|
|
@ -143,8 +143,11 @@ class SanitizationEntityView(View):
|
|||
messages.success('Sanitization data updated successfully!')
|
||||
else:
|
||||
messages.error('Error modifying Sanitization data!')
|
||||
if form.errors:
|
||||
for k in form.errors.keys():
|
||||
txt = "{}: {}".format(k, form.errors[k])
|
||||
messages.error(txt)
|
||||
|
||||
# db.session.commit()
|
||||
return flask.redirect(flask.url_for('core.user-profile'))
|
||||
|
||||
|
||||
|
|
Reference in New Issue