forked from GithubBackups/healthchecks
Don't let users clone checks if the account is at check limit
This commit is contained in:
parent
e04a92ccf1
commit
385021b44c
@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
- "Get a single check" API call now supports read-only API keys (#346)
|
- "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 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
|
## v1.14.0 - 2020-03-23
|
||||||
|
|
||||||
|
@ -16,3 +16,11 @@ class CopyCheckTestCase(BaseTestCase):
|
|||||||
r = self.client.post(self.copy_url, follow=True)
|
r = self.client.post(self.copy_url, follow=True)
|
||||||
self.assertContains(r, "This is a brand new check")
|
self.assertContains(r, "This is a brand new check")
|
||||||
self.assertContains(r, "Foo (copy)")
|
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)
|
||||||
|
@ -556,6 +556,9 @@ def transfer(request, code):
|
|||||||
def copy(request, code):
|
def copy(request, code):
|
||||||
check = _get_check_for_user(request, code)
|
check = _get_check_for_user(request, code)
|
||||||
|
|
||||||
|
if check.project.num_checks_available() <= 0:
|
||||||
|
return HttpResponseBadRequest()
|
||||||
|
|
||||||
copied = Check(project=check.project)
|
copied = Check(project=check.project)
|
||||||
copied.name = check.name + " (copy)"
|
copied.name = check.name + " (copy)"
|
||||||
copied.desc, copied.tags = check.desc, check.tags
|
copied.desc, copied.tags = check.desc, check.tags
|
||||||
|
@ -223,11 +223,13 @@
|
|||||||
<p>Copy, Transfer, or permanently remove this check.</p>
|
<p>Copy, Transfer, or permanently remove this check.</p>
|
||||||
|
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
|
{% if project.num_checks_available > 0 %}
|
||||||
<button
|
<button
|
||||||
id="copy-btn"
|
id="copy-btn"
|
||||||
data-toggle="modal"
|
data-toggle="modal"
|
||||||
data-target="#copy-modal"
|
data-target="#copy-modal"
|
||||||
class="btn btn-sm btn-default">Create a Copy…</button>
|
class="btn btn-sm btn-default">Create a Copy…</button>
|
||||||
|
{% endif %}
|
||||||
<button
|
<button
|
||||||
id="transfer-btn"
|
id="transfer-btn"
|
||||||
data-toggle="modal"
|
data-toggle="modal"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user