From 6e27d88ec9e754f755f69859ad32727412f0bc2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= <cuu508@gmail.com> Date: Fri, 12 Apr 2024 15:34:54 +0300 Subject: [PATCH] Fix the Trello integration to use Flip.new_status --- hc/api/tests/test_notify_trello.py | 4 +++- hc/api/transports.py | 6 +++--- templates/integrations/trello_name.html | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hc/api/tests/test_notify_trello.py b/hc/api/tests/test_notify_trello.py index 021bba27..485b7f85 100644 --- a/hc/api/tests/test_notify_trello.py +++ b/hc/api/tests/test_notify_trello.py @@ -18,7 +18,9 @@ class NotifyTrelloTestCase(BaseTestCase): self.check = Check(project=self.project) self.check.name = "Foo" - self.check.status = "down" + # Transport classes should use flip.new_status, + # so the status "paused" should not appear anywhere + self.check.status = "paused" self.check.last_ping = now() - td(minutes=61) self.check.save() diff --git a/hc/api/transports.py b/hc/api/transports.py index 60dfeda9..39c83530 100644 --- a/hc/api/transports.py +++ b/hc/api/transports.py @@ -1089,14 +1089,14 @@ class Trello(HttpTransport): def is_noop(self, status: str) -> bool: return status != "down" - def notify(self, check: Check, notification: Notification) -> None: + def notify_flip(self, flip: Flip, notification: Notification) -> None: if not settings.TRELLO_APP_KEY: raise TransportError("Trello notifications are not enabled.") params = { "idList": self.channel.trello.list_id, - "name": tmpl("trello_name.html", check=check), - "desc": tmpl("trello_desc.html", check=check), + "name": tmpl("trello_name.html", check=flip.owner, status=flip.new_status), + "desc": tmpl("trello_desc.html", check=flip.owner), "key": settings.TRELLO_APP_KEY, "token": self.channel.trello.token, } diff --git a/templates/integrations/trello_name.html b/templates/integrations/trello_name.html index ca3fc1fd..4a5c923a 100644 --- a/templates/integrations/trello_name.html +++ b/templates/integrations/trello_name.html @@ -1,4 +1,4 @@ -{% if check.status == "down" %} +{% if status == "down" %} Down: {{ check.name_then_code|safe }} {% else %} Up: {{ check.name_then_code|safe }}