How to use the tasklib.task.Task.DeletedTask function in tasklib

To help you get started, we’ve selected a few tasklib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github robgolding / tasklib / tasklib / tests.py View on Github external
def test_delete_deleted_task(self):
        t = Task(self.tw, description='test task')
        t.save()
        t.delete()

        self.assertRaises(Task.DeletedTask, t.delete)
github robgolding / tasklib / tasklib / task.py View on Github external
def start(self):
        if not self.saved:
            raise Task.NotSaved(
                'Task needs to be saved before it can be started',
            )

        # Refresh, and raise exception if task is already completed/deleted
        self.refresh(only_fields=['status'])

        if self.completed:
            raise Task.CompletedTask('Cannot start a completed task')
        elif self.deleted:
            raise Task.DeletedTask('Deleted task cannot be started')
        elif self.active:
            raise Task.ActiveTask('Task is already active')

        self.backend.start_task(self)

        # Refresh the status again, so that we have updated info stored
        self.refresh(only_fields=['status', 'start'])
github scottkosty / vit / vit / task.py View on Github external
def task_delete(self, uuid):
        task = self.get_task(uuid)
        if task:
            try:
                task.delete()
                return True, task
            except Task.DeletedTask as e:
                return False, e
        return False, None
github robgolding / tasklib / tasklib / task.py View on Github external
def delete(self):
        if not self.saved:
            raise Task.NotSaved(
                'Task needs to be saved before it can be deleted',
            )

        # Refresh the status, and raise exception if the task is deleted
        self.refresh(only_fields=['status'])

        if self.deleted:
            raise Task.DeletedTask('Task was already deleted')

        self.backend.delete_task(self)

        # Refresh the status again, so that we have updated info stored
        self.refresh(only_fields=['status', 'start', 'end'])
github robgolding / tasklib / tasklib / task.py View on Github external
def done(self):
        if not self.saved:
            raise Task.NotSaved(
                'Task needs to be saved before it can be completed',
            )

        # Refresh, and raise exception if task is already completed/deleted
        self.refresh(only_fields=['status'])

        if self.completed:
            raise Task.CompletedTask('Cannot complete a completed task')
        elif self.deleted:
            raise Task.DeletedTask('Deleted task cannot be completed')

        self.backend.complete_task(self)

        # Refresh the status again, so that we have updated info stored
        self.refresh(only_fields=['status', 'start', 'end'])