forked from GithubBackups/healthchecks
Profile.set_next_nag_date does not touch already set dates.
This commit is contained in:
parent
5c64e0cd5d
commit
2a7ee66d1e
@ -203,8 +203,8 @@ class Profile(models.Model):
|
||||
is_member = models.Q(user__memberships__team=self)
|
||||
q = Profile.objects.filter(is_owner | is_member)
|
||||
q = q.exclude(nag_period=NO_NAG)
|
||||
# Exclude profiles with next_nag_date in future
|
||||
q = q.exclude(next_nag_date__gt=timezone.now())
|
||||
# Exclude profiles with next_nag_date already set
|
||||
q = q.filter(next_nag_date__isnull=True)
|
||||
|
||||
q.update(next_nag_date=timezone.now() + models.F("nag_period"))
|
||||
|
||||
|
@ -122,8 +122,8 @@ class SendAlertsTestCase(BaseTestCase):
|
||||
self.bobs_profile.refresh_from_db()
|
||||
self.assertIsNotNone(self.bobs_profile.next_nag_date)
|
||||
|
||||
def test_it_does_not_touch_future_next_nag_dates(self):
|
||||
original_nag_date = now() + timedelta(minutes=30)
|
||||
def test_it_does_not_touch_already_set_next_nag_dates(self):
|
||||
original_nag_date = now() - timedelta(minutes=30)
|
||||
self.profile.nag_period = timedelta(hours=1)
|
||||
self.profile.next_nag_date = original_nag_date
|
||||
self.profile.save()
|
||||
|
Loading…
x
Reference in New Issue
Block a user