# Coverage for api/html.py : 75%

## 12 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"""

2 Used on flash

3 flash(notify_success('mail sent!'))

4"""

5

6

7 def notify(message, alert_type="primary"):

8 """

9 Used with flash

10 flash(notify('blabla'))

11

12 Parameters

13 ----------

14 message: str

15 message to be displayed

16

17 alert_type: str

18 bootstrap class

19

20 Returns

21 -------

22 None

23 """

24 alert = """

25 <div class="shopyo-alert alert alert-{alert_type} alert-dismissible

26 fade show" role="alert" style="opacity: 0.98;">

27 {message}

28

29 <button type="button" class="close" data-dismiss="alert" aria-label="Close">

30 <span aria-hidden="true">&times;</span>

31 </button>

32 </div>

33 """.format(

34 message=message, alert_type=alert_type

35 )

36

37 scriptFade = """

38 <script>

39 setTimeout(function() {

40 $('#flashed-messages').fadeOut('fast');

41 }, 5000); // <-- time in milliseconds (5 secs)

42 </script>

43 """

44 return alert + scriptFade

45

46

47 def notify_success(message):

48 return notify(message, alert_type="success")

49

50

51 def notify_danger(message):

52 return notify(message, alert_type="danger")

53

54

55 def notify_warning(message):

56 return notify(message, alert_type="warning")

57

58

59 def notify_info(message):

60 return notify(message, alert_type="info")