diff --git a/hc/front/tests/test_details.py b/hc/front/tests/test_details.py index c8d68e6b..4e34b698 100644 --- a/hc/front/tests/test_details.py +++ b/hc/front/tests/test_details.py @@ -24,6 +24,7 @@ class DetailsTestCase(BaseTestCase): self.client.login(username="alice@example.org", password="password") r = self.client.get(self.url) self.assertContains(r, "How To Ping", status_code=200) + self.assertContains(r, "ping-now") # The page should contain timezone strings self.assertContains(r, "Europe/Riga") @@ -153,3 +154,26 @@ class DetailsTestCase(BaseTestCase): # The summary for Dec. 2019 should be "–" self.assertContains(r, "–", html=True) + + def test_it_handles_no_ping_key(self): + self.project.show_slugs = True + self.project.ping_key = None + self.project.save() + + self.client.login(username="alice@example.org", password="password") + r = self.client.get(self.url) + self.assertContains(r, "Ping Key Required", status_code=200) + self.assertNotContains(r, "ping-now") + + def test_it_handles_no_ping_key_for_readonly_user(self): + self.project.show_slugs = True + self.project.ping_key = None + self.project.save() + + self.bobs_membership.role = "r" + self.bobs_membership.save() + self.client.login(username="bob@example.org", password="password") + + r = self.client.get(self.url) + self.assertNotContains(r, "Ping Key Required", status_code=200) + self.assertNotContains(r, "ping-now") diff --git a/templates/front/details.html b/templates/front/details.html index bc7ddbd7..f4f5f253 100644 --- a/templates/front/details.html +++ b/templates/front/details.html @@ -142,10 +142,19 @@ {% endif %} + {% if project.show_slugs and not project.ping_key %} + {% if rw %} + + {% endif %} + {% else %} + {% endif %} @@ -317,6 +326,29 @@ {% include "front/filtering_rules_modal.html" %} {% include "front/copy_modal.html" %} +{% if rw and project.show_slugs and not project.ping_key %} + +{% endif %} + {% endblock %} {% block scripts %}