From: Tomas Babej Date: Sat, 8 Aug 2015 20:16:48 +0000 (+0200) Subject: backends: Move TW-specific annotation logic to TW backend X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/commitdiff_plain/1a429b9309cf543e937c9b8b061d0f99d1acffbe?ds=inline backends: Move TW-specific annotation logic to TW backend --- diff --git a/tasklib/backends.py b/tasklib/backends.py index a1d858f..f0c73ef 100644 --- a/tasklib/backends.py +++ b/tasklib/backends.py @@ -241,6 +241,14 @@ class TaskWarrior(object): self.execute_command([task['uuid'], 'done']) + def annotate_task(self, task, annotation): + args = [task['uuid'], 'annotate', annotation] + self.execute_command(args) + + def denotate_task(self, task, annotation): + args = [task['uuid'], 'denotate', annotation] + self.execute_command(args) + def refresh_task(self, task, after_save=False): # We need to use ID as backup for uuid here for the refreshes # of newly saved tasks. Any other place in the code is fine diff --git a/tasklib/task.py b/tasklib/task.py index 5a86529..9ae63d4 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -653,8 +653,7 @@ class Task(TaskResource): if not self.saved: raise Task.NotSaved("Task needs to be saved to add annotation") - args = [self['uuid'], 'annotate', annotation] - self.warrior.execute_command(args) + self.backend.annotate_task(self, annotation) self.refresh(only_fields=['annotations']) def remove_annotation(self, annotation): @@ -663,8 +662,8 @@ class Task(TaskResource): if isinstance(annotation, TaskAnnotation): annotation = annotation['description'] - args = [self['uuid'], 'denotate', annotation] - self.warrior.execute_command(args) + + self.backend.denotate_task(self, annotation) self.refresh(only_fields=['annotations']) def _get_modified_fields_as_args(self):