Browse Source

Read-only users cannot resume checks.

pull/419/head
Pēteris Caune 4 years ago
parent
commit
24c34430ac
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
4 changed files with 24 additions and 1 deletions
  1. +13
    -0
      hc/front/tests/test_details.py
  2. +8
    -0
      hc/front/tests/test_resume.py
  3. +1
    -1
      hc/front/views.py
  4. +2
    -0
      templates/front/log_status_text.html

+ 13
- 0
hc/front/tests/test_details.py View File

@ -61,3 +61,16 @@ class DetailsTestCase(BaseTestCase):
self.assertNotContains(r, "Create a Copy…") self.assertNotContains(r, "Create a Copy…")
self.assertNotContains(r, "transfer-btn") self.assertNotContains(r, "transfer-btn")
self.assertNotContains(r, "details-remove-check") self.assertNotContains(r, "details-remove-check")
def test_it_hides_resume_action_from_readonly_users(self):
self.bobs_membership.rw = False
self.bobs_membership.save()
self.check.status = "paused"
self.check.manual_resume = True
self.check.save()
self.client.login(username="[email protected]", password="password")
r = self.client.get(self.url)
self.assertNotContains(r, "resume-btn", status_code=200)

+ 8
- 0
hc/front/tests/test_resume.py View File

@ -26,3 +26,11 @@ class ResumeTestCase(BaseTestCase):
self.client.login(username="[email protected]", password="password") self.client.login(username="[email protected]", password="password")
r = self.client.post(self.url) r = self.client.post(self.url)
self.assertRedirects(r, self.redirect_url) self.assertRedirects(r, self.redirect_url)
def test_it_requires_rw_access(self):
self.bobs_membership.rw = False
self.bobs_membership.save()
self.client.login(username="[email protected]", password="password")
r = self.client.post(self.url)
self.assertEqual(r.status_code, 403)

+ 1
- 1
hc/front/views.py View File

@ -494,7 +494,7 @@ def pause(request, code):
@require_POST @require_POST
@login_required @login_required
def resume(request, code): def resume(request, code):
check, rw = _get_check_for_user(request, code)
check = _get_rw_check_for_user(request, code)
check.status = "new" check.status = "new"
check.last_start = None check.last_start = None


+ 2
- 0
templates/front/log_status_text.html View File

@ -8,7 +8,9 @@
This check is late. Last ping was {{ check.last_ping|naturaltime }}. This check is late. Last ping was {{ check.last_ping|naturaltime }}.
{% elif status == "paused" and check.manual_resume %} {% elif status == "paused" and check.manual_resume %}
This check is paused, and will ignore pings until resumed. This check is paused, and will ignore pings until resumed.
{% if rw %}
<a id="resume-btn" href="#">(Resume&nbsp;Now)</a> <a id="resume-btn" href="#">(Resume&nbsp;Now)</a>
{% endif %}
{% elif status == "paused" %} {% elif status == "paused" %}
This check is paused. This check is paused.
{% elif status == "new" and check.n_pings %} {% elif status == "new" and check.n_pings %}


Loading…
Cancel
Save