コード例 #1
0
ファイル: sendreminders.py プロジェクト: rboulton/behabitual
 def handle(self, *args, **kwargs):
     """
     Send all pending habit reminders. This command should be called on a
     cronjob once an hour (ideally shortly after the top of the hour).
     """
     now = timezone.now().replace(minute=0, second=0, microsecond=0)
     for habit in Habit.scheduled_for_reminder(now.weekday(), now.hour):
         # Only send the reminder if either
         #   a) the habit has never had any reminders send for it
         #   b) the habit last had a reminder sent at least an hour ago
         if habit.reminder_last_sent is None or habit.reminder_last_sent < now:
             habit.reminder_last_sent = now
             habit.save()
             send_reminder_email(habit)
コード例 #2
0
ファイル: sendreminders.py プロジェクト: devfort/behabitual
 def handle(self, *args, **kwargs):
     """
     Send all pending habit reminders. This command should be called on a
     cronjob once an hour (ideally shortly after the top of the hour).
     """
     now = timezone.now().replace(minute=0, second=0, microsecond=0)
     for habit in Habit.scheduled_for_reminder(now.weekday(), now.hour):
         # Only send the reminder if either
         #   a) the habit has never had any reminders send for it
         #   b) the habit last had a reminder sent at least an hour ago
         if habit.reminder_last_sent is None or habit.reminder_last_sent < now:
             habit.reminder_last_sent = now
             habit.save()
             send_reminder_email(habit)
コード例 #3
0
ファイル: test_reminders.py プロジェクト: rboulton/behabitual
    def test_send_reminder_email_for_archived_habit(self):
        self.h.archived = True

        result = send_reminder_email(self.h)

        self.assertIsNone(result)
        self.assertEqual(len(mail.outbox), 0)
コード例 #4
0
ファイル: test_reminders.py プロジェクト: rboulton/behabitual
    def test_send_reminder_email_for_archived_habit(self):
        self.h.archived = True

        result = send_reminder_email(self.h)

        self.assertIsNone(result)
        self.assertEqual(len(mail.outbox), 0)
コード例 #5
0
ファイル: test_reminders.py プロジェクト: eachan/behabitual
    def test_send_reminder_email(self):
        send_reminder_email(self.h)

        self.assertEqual(len(mail.outbox), 1)
        self.assertTrue('Frobble your wingdangle' in mail.outbox[0].subject)
コード例 #6
0
ファイル: test_reminders.py プロジェクト: rboulton/behabitual
    def test_send_reminder_email(self):
        send_reminder_email(self.h)

        self.assertEqual(len(mail.outbox), 1)
        self.assertTrue('Frobble your wingdangle' in mail.outbox[0].subject)