diff --git a/CHANGELOG.md b/CHANGELOG.md index 96de2b4a..cdbd80b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog All notable changes to this project will be documented in this file. +## Unreleased + +### Improvements +- Add the "desc" field (check's description) to API responses + + ## 1.5.0 - 2019-02-04 ### Improvements diff --git a/hc/api/models.py b/hc/api/models.py index 91cffca6..c9f29e69 100644 --- a/hc/api/models.py +++ b/hc/api/models.py @@ -193,7 +193,8 @@ class Check(models.Model): "status": self.get_status(), "channels": ",".join(sorted(channel_codes)), "last_ping": isostring(self.last_ping), - "next_ping": isostring(self.get_grace_start()) + "next_ping": isostring(self.get_grace_start()), + "desc": self.desc } if self.kind == "simple": diff --git a/hc/api/tests/test_list_checks.py b/hc/api/tests/test_list_checks.py index 434bd767..9b2f6b6d 100644 --- a/hc/api/tests/test_list_checks.py +++ b/hc/api/tests/test_list_checks.py @@ -20,6 +20,7 @@ class ListChecksTestCase(BaseTestCase): self.a1.n_pings = 0 self.a1.status = "new" self.a1.tags = "a1-tag a1-additional-tag" + self.a1.desc = "This is description" self.a1.save() self.a2 = Check(project=self.project, name="Alice 2") @@ -56,6 +57,7 @@ class ListChecksTestCase(BaseTestCase): self.assertEqual(a1["n_pings"], 0) self.assertEqual(a1["status"], "new") self.assertEqual(a1["channels"], str(self.c1.code)) + self.assertEqual(a1["desc"], "This is description") update_url = settings.SITE_ROOT + "/api/v1/checks/%s" % self.a1.code pause_url = update_url + "/pause" diff --git a/templates/front/snippets/create_check_response.html b/templates/front/snippets/create_check_response.html index 9704dcea..56da02f6 100644 --- a/templates/front/snippets/create_check_response.html +++ b/templates/front/snippets/create_check_response.html @@ -1,5 +1,6 @@
{
"channels": "",
+ "desc": "",
"grace": 60,
"last_ping": null,
"n_pings": 0,
diff --git a/templates/front/snippets/create_check_response.txt b/templates/front/snippets/create_check_response.txt
index 26caca1f..3465b42b 100644
--- a/templates/front/snippets/create_check_response.txt
+++ b/templates/front/snippets/create_check_response.txt
@@ -1,5 +1,6 @@
{
"channels": "",
+ "desc": "",
"grace": 60,
"last_ping": null,
"n_pings": 0,
diff --git a/templates/front/snippets/list_checks_response.html b/templates/front/snippets/list_checks_response.html
index 0ae95302..a13b6556 100644
--- a/templates/front/snippets/list_checks_response.html
+++ b/templates/front/snippets/list_checks_response.html
@@ -1,8 +1,9 @@
{
"checks": [
{
- "channels": "4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc"
- "grace": 900,
+ "channels": "4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc",
+ "desc": "Longer free-form description goes here",
+ "grace": 900,
"last_ping": "2017-01-04T13:24:39.903464+00:00",
"n_pings": 1,
"name": "Api test 1",
@@ -16,6 +17,7 @@
},
{
"channels": "",
+ "desc": "",
"grace": 3600,
"last_ping": null,
"n_pings": 0,
diff --git a/templates/front/snippets/list_checks_response.txt b/templates/front/snippets/list_checks_response.txt
index b4f33a9f..425412e1 100644
--- a/templates/front/snippets/list_checks_response.txt
+++ b/templates/front/snippets/list_checks_response.txt
@@ -1,7 +1,8 @@
{
"checks": [
{
- "channels": "4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc"
+ "channels": "4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc",
+ "desc": "Longer free-form description goes here",
"grace": 900,
"last_ping": "2017-01-04T13:24:39.903464+00:00",
"n_pings": 1,
@@ -16,6 +17,7 @@
},
{
"channels": "",
+ "desc": "",
"grace": 3600,
"last_ping": null,
"n_pings": 0,
diff --git a/templates/front/snippets/pause_check_response.html b/templates/front/snippets/pause_check_response.html
index 6a0301fc..8300d7f9 100644
--- a/templates/front/snippets/pause_check_response.html
+++ b/templates/front/snippets/pause_check_response.html
@@ -1,4 +1,6 @@
{
+ "channels": "",
+ "desc": "",
"grace": 60,
"last_ping": null,
"n_pings": 0,
diff --git a/templates/front/snippets/pause_check_response.txt b/templates/front/snippets/pause_check_response.txt
index 70039d68..d06b5654 100644
--- a/templates/front/snippets/pause_check_response.txt
+++ b/templates/front/snippets/pause_check_response.txt
@@ -1,4 +1,6 @@
{
+ "channels": "",
+ "desc": "",
"grace": 60,
"last_ping": null,
"n_pings": 0,