forked from GithubBackups/healthchecks
Fix the "Email Reports" screen to clear Profile.next_nag_date
This commit is contained in:
parent
1d6b75d5dc
commit
68b1d5bb8b
@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Relax cron expression validation: accept all expressions that croniter accepts
|
- Relax cron expression validation: accept all expressions that croniter accepts
|
||||||
- Fix sendalerts to clear Profile.next_nag_date if all checks up
|
- Fix sendalerts to clear Profile.next_nag_date if all checks up
|
||||||
- Fix the pause action to clear Profile.next_nag_date if all checks up
|
- Fix the pause action to clear Profile.next_nag_date if all checks up
|
||||||
|
- Fix the "Email Reports" screen to clear Profile.next_nag_date if all checks up
|
||||||
|
|
||||||
## v1.19.0 - 2021-02-03
|
## v1.19.0 - 2021-02-03
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from datetime import timedelta as td
|
from datetime import timedelta as td
|
||||||
|
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
|
from hc.api.models import Check
|
||||||
from hc.test import BaseTestCase
|
from hc.test import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
@ -34,7 +35,9 @@ class NotificationsTestCase(BaseTestCase):
|
|||||||
self.assertFalse(self.profile.reports_allowed)
|
self.assertFalse(self.profile.reports_allowed)
|
||||||
self.assertIsNone(self.profile.next_report_date)
|
self.assertIsNone(self.profile.next_report_date)
|
||||||
|
|
||||||
def test_it_saves_hourly_nag_period(self):
|
def test_it_sets_next_nag_date_when_setting_hourly_nag_period(self):
|
||||||
|
Check.objects.create(project=self.project, status="down")
|
||||||
|
|
||||||
self.client.login(username="alice@example.org", password="password")
|
self.client.login(username="alice@example.org", password="password")
|
||||||
|
|
||||||
form = {"nag_period": "3600"}
|
form = {"nag_period": "3600"}
|
||||||
@ -45,6 +48,20 @@ class NotificationsTestCase(BaseTestCase):
|
|||||||
self.assertEqual(self.profile.nag_period.total_seconds(), 3600)
|
self.assertEqual(self.profile.nag_period.total_seconds(), 3600)
|
||||||
self.assertIsNotNone(self.profile.next_nag_date)
|
self.assertIsNotNone(self.profile.next_nag_date)
|
||||||
|
|
||||||
|
def test_it_clears_next_nag_date_when_setting_hourly_nag_period(self):
|
||||||
|
self.profile.next_nag_date = now() + td(minutes=30)
|
||||||
|
self.profile.save()
|
||||||
|
|
||||||
|
self.client.login(username="alice@example.org", password="password")
|
||||||
|
|
||||||
|
form = {"nag_period": "3600"}
|
||||||
|
r = self.client.post("/accounts/profile/notifications/", form)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
self.profile.refresh_from_db()
|
||||||
|
self.assertEqual(self.profile.nag_period.total_seconds(), 3600)
|
||||||
|
self.assertIsNone(self.profile.next_nag_date)
|
||||||
|
|
||||||
def test_it_does_not_save_nonstandard_nag_period(self):
|
def test_it_does_not_save_nonstandard_nag_period(self):
|
||||||
self.profile.nag_period = td(seconds=3600)
|
self.profile.nag_period = td(seconds=3600)
|
||||||
self.profile.save()
|
self.profile.save()
|
||||||
|
@ -457,9 +457,9 @@ def notifications(request):
|
|||||||
if profile.nag_period != form.cleaned_data["nag_period"]:
|
if profile.nag_period != form.cleaned_data["nag_period"]:
|
||||||
# Set the new nag period
|
# Set the new nag period
|
||||||
profile.nag_period = form.cleaned_data["nag_period"]
|
profile.nag_period = form.cleaned_data["nag_period"]
|
||||||
# and schedule next_nag_date:
|
# and update next_nag_date:
|
||||||
if profile.nag_period:
|
if profile.nag_period:
|
||||||
profile.next_nag_date = now() + profile.nag_period
|
profile.update_next_nag_date()
|
||||||
else:
|
else:
|
||||||
profile.next_nag_date = None
|
profile.next_nag_date = None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user