diff --git a/hc/accounts/models.py b/hc/accounts/models.py index 5a7d6970..01b00e8e 100644 --- a/hc/accounts/models.py +++ b/hc/accounts/models.py @@ -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")) diff --git a/hc/api/tests/test_sendalerts.py b/hc/api/tests/test_sendalerts.py index 8464f9a9..2275adfa 100644 --- a/hc/api/tests/test_sendalerts.py +++ b/hc/api/tests/test_sendalerts.py @@ -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()