ass form errors in message

This commit is contained in:
Cayo Puigdefabregas 2022-04-29 17:53:59 +02:00
parent 322b340607
commit 7fe33f3a42
2 changed files with 5 additions and 0 deletions

View File

@ -354,6 +354,9 @@ class NewAllocateView(NewActionView, DeviceListMix):
return flask.redirect(next_url)
messages.error('Action {} error!'.format(self.form.type.data))
for k, v in self.form.errors.items():
value = ';'.join(v)
messages.error('Action Error {key}: {value}!'.format(key=k, value=value))
next_url = self.get_next_url()
return flask.redirect(next_url)

View File

@ -668,6 +668,7 @@ def test_action_allocate_error_required(user3: UserClientFlask):
body, status = user3.post(uri, data=data)
assert status == '200 OK'
assert 'Action Allocate error' in body
assert 'You need to specify a number of users!' in body
@pytest.mark.mvp
@ -692,6 +693,7 @@ def test_action_allocate_error_dates(user3: UserClientFlask):
body, status = user3.post(uri, data=data)
assert status == '200 OK'
assert 'Action Allocate error' in body
assert 'The action cannot finish before it starts.' in body
assert dev.actions[-1].type != 'Allocate'