Coverage for api/forms.py: 27%

# Coverage for api/forms.py : 27%

## 7 statements

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 from flask import flash

2

3 from shopyo.api.html import notify_warning

4

5

6 def flash_errors(form):

7 """

8 Auto flash errors from WKHtml forms

9 Reqwires base module or similar notification

10 mechanism

11

12 Parameters

13 ----------

14 form: WKHtml form

15

16 Returns

17 -------

18 None

19 """

20 for field, errors in form.errors.items():

21 for error in errors:

22 error_msg = "Error in the {} field - {}".format(

23 getattr(form, field).label.text,

24 error,

25 )

26 flash(notify_warning(error_msg))