From dcbdcdd11c981b4600ea4a5522230d0456e45d21 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sat, 8 Aug 2015 19:58:18 +0200 Subject: [PATCH 1/1] Task: Move TW-specific start/stop logic into TW backend --- tasklib/backends.py | 5 +++++ tasklib/task.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tasklib/backends.py b/tasklib/backends.py index 6bf11bb..12a9234 100644 --- a/tasklib/backends.py +++ b/tasklib/backends.py @@ -204,3 +204,8 @@ class TaskWarrior(object): def delete_task(self, task): self.execute_command([task['uuid'], 'delete']) + def start_task(self, task): + self.execute_command([task['uuid'], 'start']) + + def stop_task(self, task): + self.execute_command([task['uuid'], 'stop']) diff --git a/tasklib/task.py b/tasklib/task.py index 61f944a..b7bba4b 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -605,7 +605,7 @@ class Task(TaskResource): elif self.active: raise Task.ActiveTask("Task is already active") - self.warrior.execute_command([self['uuid'], 'start']) + self.backend.start_task(self) # Refresh the status again, so that we have updated info stored self.refresh(only_fields=['status', 'start']) @@ -620,7 +620,7 @@ class Task(TaskResource): if not self.active: raise Task.InactiveTask("Cannot stop an inactive task") - self.warrior.execute_command([self['uuid'], 'stop']) + self.backend.stop_task(self) # Refresh the status again, so that we have updated info stored self.refresh(only_fields=['status', 'start']) -- 2.39.5