Coverage for api/html.py : 75%

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"""
2Used on flash
3flash(notify_success('mail sent!'))
4"""
7def notify(message, alert_type="primary"):
8 """
9 Used with flash
10 flash(notify('blabla'))
12 Parameters
13 ----------
14 message: str
15 message to be displayed
17 alert_type: str
18 bootstrap class
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}
29 <button type="button" class="close" data-dismiss="alert" aria-label="Close">
30 <span aria-hidden="true">×</span>
31 </button>
32 </div>
33 """.format(
34 message=message, alert_type=alert_type
35 )
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
47def notify_success(message):
48 return notify(message, alert_type="success")
51def notify_danger(message):
52 return notify(message, alert_type="danger")
55def notify_warning(message):
56 return notify(message, alert_type="warning")
59def notify_info(message):
60 return notify(message, alert_type="info")