diff --git a/CHANGELOG.md b/CHANGELOG.md index 68402b37..2936923a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. ### Bug Fixes - "Get a single check" API call now supports read-only API keys (#346) - Don't escape HTML in the subject line of notification emails +- Don't let users clone checks if the account is at check limit ## v1.14.0 - 2020-03-23 diff --git a/hc/front/tests/test_copy.py b/hc/front/tests/test_copy.py index 1b91bd1d..d39e5132 100644 --- a/hc/front/tests/test_copy.py +++ b/hc/front/tests/test_copy.py @@ -16,3 +16,11 @@ class CopyCheckTestCase(BaseTestCase): r = self.client.post(self.copy_url, follow=True) self.assertContains(r, "This is a brand new check") self.assertContains(r, "Foo (copy)") + + def test_it_obeys_limit(self): + self.profile.check_limit = 0 + self.profile.save() + + self.client.login(username="alice@example.org", password="password") + r = self.client.post(self.copy_url) + self.assertEqual(r.status_code, 400) diff --git a/hc/front/views.py b/hc/front/views.py index dac50101..8027c428 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -556,6 +556,9 @@ def transfer(request, code): def copy(request, code): check = _get_check_for_user(request, code) + if check.project.num_checks_available() <= 0: + return HttpResponseBadRequest() + copied = Check(project=check.project) copied.name = check.name + " (copy)" copied.desc, copied.tags = check.desc, check.tags diff --git a/templates/front/details.html b/templates/front/details.html index e3ecf129..cc9e32db 100644 --- a/templates/front/details.html +++ b/templates/front/details.html @@ -223,11 +223,13 @@
Copy, Transfer, or permanently remove this check.