Browse Source

Profile.set_next_nag_date does not touch already set dates.

pull/140/head
Pēteris Caune 7 years ago
parent
commit
2a7ee66d1e
2 changed files with 4 additions and 4 deletions
  1. +2
    -2
      hc/accounts/models.py
  2. +2
    -2
      hc/api/tests/test_sendalerts.py

+ 2
- 2
hc/accounts/models.py View File

@ -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"))


+ 2
- 2
hc/api/tests/test_sendalerts.py View File

@ -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…
Cancel
Save