Skip to content

Commit

Permalink
Merge PR #2949 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Oct 9, 2024
2 parents 602d6e8 + fd3c2c6 commit d2e12ad
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .oca/oca-port/blacklist/web_notify.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"pull_requests": {
"1724": "(auto) Nothing to port from PR #1724"
}
}
17 changes: 12 additions & 5 deletions web_notify/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ def notify_success(
sticky=False,
target=None,
action=None,
params=None,
):
title = title or _("Success")
self._notify_channel(SUCCESS, message, title, sticky, target, action)
self._notify_channel(SUCCESS, message, title, sticky, target, action, params)

def notify_danger(
self,
Expand All @@ -60,9 +61,10 @@ def notify_danger(
sticky=False,
target=None,
action=None,
params=None,
):
title = title or _("Danger")
self._notify_channel(DANGER, message, title, sticky, target, action)
self._notify_channel(DANGER, message, title, sticky, target, action, params)

def notify_warning(
self,
Expand All @@ -71,9 +73,10 @@ def notify_warning(
sticky=False,
target=None,
action=None,
params=None,
):
title = title or _("Warning")
self._notify_channel(WARNING, message, title, sticky, target, action)
self._notify_channel(WARNING, message, title, sticky, target, action, params)

def notify_info(
self,
Expand All @@ -82,9 +85,10 @@ def notify_info(
sticky=False,
target=None,
action=None,
params=None,
):
title = title or _("Information")
self._notify_channel(INFO, message, title, sticky, target, action)
self._notify_channel(INFO, message, title, sticky, target, action, params)

def notify_default(
self,
Expand All @@ -93,9 +97,10 @@ def notify_default(
sticky=False,
target=None,
action=None,
params=None,
):
title = title or _("Default")
self._notify_channel(DEFAULT, message, title, sticky, target, action)
self._notify_channel(DEFAULT, message, title, sticky, target, action, params)

def _notify_channel(
self,
Expand All @@ -105,6 +110,7 @@ def _notify_channel(
sticky=False,
target=None,
action=None,
params=None,
):
if not (self.env.user._is_admin() or self.env.su) and any(
user.id != self.env.uid for user in self
Expand All @@ -122,6 +128,7 @@ def _notify_channel(
"title": title,
"sticky": sticky,
"action": action,
"params": dict(params or []),
}

notifications = [[partner, "web.notify", [bus_message]] for partner in target]
Expand Down
5 changes: 5 additions & 0 deletions web_notify/tests/test_res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def test_notify_success(self):
"title": "title",
"sticky": True,
"action": None,
"params": {},
}
self.env.user.notify_success(**test_msg)
news = bus_bus.search(domain) - existing
Expand All @@ -36,6 +37,7 @@ def test_notify_danger(self):
"title": "title",
"sticky": True,
"action": None,
"params": {},
}
self.env.user.notify_danger(**test_msg)
news = bus_bus.search(domain) - existing
Expand All @@ -53,6 +55,7 @@ def test_notify_warning(self):
"title": "title",
"sticky": True,
"action": None,
"params": {},
}
self.env.user.notify_warning(**test_msg)
news = bus_bus.search(domain) - existing
Expand All @@ -70,6 +73,7 @@ def test_notify_info(self):
"title": "title",
"sticky": True,
"action": None,
"params": {},
}
self.env.user.notify_info(**test_msg)
news = bus_bus.search(domain) - existing
Expand All @@ -87,6 +91,7 @@ def test_notify_default(self):
"title": "title",
"sticky": True,
"action": None,
"params": {},
}
self.env.user.notify_default(**test_msg)
news = bus_bus.search(domain) - existing
Expand Down

0 comments on commit d2e12ad

Please sign in to comment.