コード例 #1
0
    def process_notifications(self):
        """Changes notification status from CREATED to PENDING if it's time to show notification"""

        for notification in Notification.select().where(
                Notification.status == NotificationStatus.CREATED.value).join(
                    Task).where(Task.id == Notification.task_id):
            task = Task.get(Task.id == notification.task_id)
            if (task.start_time - datetime.timedelta(
                    seconds=notification.relative_start_time)
                ) < datetime.datetime.now():
                notification.status = NotificationStatus.PENDING.value
                notification.save()
コード例 #2
0
 def test_updates_task(self):
     task_with_id = self.task_storage.create(self.task)
     task_with_id.title = "Do something great"
     self.task_storage.update(task_with_id)
     task_from_db = Task.get(Task.id == task_with_id.id)
     self.assertEqual(task_from_db.title, "Do something great")
コード例 #3
0
 def get_by_id(self, task_id):
     try:
         return self.to_task_instance(Task.get(Task.id == task_id))
     except DoesNotExist:
         return None