Skip to content

Commit c9ec4c5

Browse files
committed
[IMP] web_notity: HTML formatting
1 parent 00c5a2f commit c9ec4c5

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

web_notify/models/res_users.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,58 +49,71 @@ def notify_success(
4949
sticky=False,
5050
target=None,
5151
action=None,
52+
html=False,
5253
params=None,
5354
):
5455
title = title or _("Success")
55-
self._notify_channel(SUCCESS, message, title, sticky, target, action, params)
56+
self._notify_channel(
57+
SUCCESS, message, title, sticky, target, html, action, params
58+
)
5659

5760
def notify_danger(
5861
self,
5962
message="Default message",
6063
title=None,
6164
sticky=False,
6265
target=None,
66+
html=False,
6367
action=None,
6468
params=None,
6569
):
6670
title = title or _("Danger")
67-
self._notify_channel(DANGER, message, title, sticky, target, action, params)
71+
self._notify_channel(
72+
DANGER, message, title, sticky, target, html, action, params
73+
)
6874

6975
def notify_warning(
7076
self,
7177
message="Default message",
7278
title=None,
7379
sticky=False,
7480
target=None,
81+
html=False,
7582
action=None,
7683
params=None,
7784
):
7885
title = title or _("Warning")
79-
self._notify_channel(WARNING, message, title, sticky, target, action, params)
86+
self._notify_channel(
87+
WARNING, message, title, sticky, target, html, action, params
88+
)
8089

8190
def notify_info(
8291
self,
8392
message="Default message",
8493
title=None,
8594
sticky=False,
8695
target=None,
96+
html=False,
8797
action=None,
8898
params=None,
8999
):
90100
title = title or _("Information")
91-
self._notify_channel(INFO, message, title, sticky, target, action, params)
101+
self._notify_channel(INFO, message, title, sticky, target, html, action, params)
92102

93103
def notify_default(
94104
self,
95105
message="Default message",
96106
title=None,
97107
sticky=False,
98108
target=None,
109+
html=False,
99110
action=None,
100111
params=None,
101112
):
102113
title = title or _("Default")
103-
self._notify_channel(DEFAULT, message, title, sticky, target, action, params)
114+
self._notify_channel(
115+
DEFAULT, message, title, sticky, target, html, action, params
116+
)
104117

105118
def _notify_channel(
106119
self,
@@ -109,6 +122,7 @@ def _notify_channel(
109122
title=None,
110123
sticky=False,
111124
target=None,
125+
html=False,
112126
action=None,
113127
params=None,
114128
):
@@ -127,6 +141,7 @@ def _notify_channel(
127141
"message": message,
128142
"title": title,
129143
"sticky": sticky,
144+
"html": html,
130145
"action": action,
131146
"params": dict(params or []),
132147
}

web_notify/static/src/js/services/notification_services.esm.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const webNotificationService = {
2929
type: notification.type,
3030
sticky: notification.sticky,
3131
className: notification.className,
32+
messageIsHtml: notification.html,
3233
buttons: buttons.map((button) => {
3334
const onClick = button.onClick;
3435
button.onClick = async () => {

web_notify/tests/test_res_users.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def test_notify_success(self):
1818
"message": "message",
1919
"title": "title",
2020
"sticky": True,
21+
"html": False,
2122
"action": None,
2223
"params": {},
2324
}
@@ -37,6 +38,7 @@ def test_notify_danger(self):
3738
"message": "message",
3839
"title": "title",
3940
"sticky": True,
41+
"html": False,
4042
"action": None,
4143
"params": {},
4244
}
@@ -56,6 +58,7 @@ def test_notify_warning(self):
5658
"message": "message",
5759
"title": "title",
5860
"sticky": True,
61+
"html": False,
5962
"action": None,
6063
"params": {},
6164
}
@@ -75,6 +78,7 @@ def test_notify_info(self):
7578
"message": "message",
7679
"title": "title",
7780
"sticky": True,
81+
"html": False,
7882
"action": None,
7983
"params": {},
8084
}
@@ -94,6 +98,7 @@ def test_notify_default(self):
9498
"message": "message",
9599
"title": "title",
96100
"sticky": True,
101+
"html": False,
97102
"action": None,
98103
"params": {},
99104
}

web_notify_channel_message/models/res_users.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def _notify_channel(
1111
title=None,
1212
sticky=False,
1313
target=None,
14+
html=False,
1415
action=None,
1516
params=None,
1617
):
@@ -21,6 +22,7 @@ def _notify_channel(
2122
title=title,
2223
sticky=sticky,
2324
target=target,
25+
html=html,
2426
action=action,
2527
params=params,
2628
)
@@ -30,6 +32,7 @@ def _notify_channel(
3032
title=title,
3133
sticky=sticky,
3234
target=target,
35+
html=html,
3336
action=action,
3437
params=params,
3538
)

0 commit comments

Comments
 (0)