Update client lib with some useful functions
still not finished
This commit is contained in:
@@ -67,7 +67,23 @@ class ACClient:
|
||||
(project_id, task_id, subtask_id),
|
||||
data=data)
|
||||
|
||||
def delete_subtask(self, subtask):
|
||||
def subtask_is_completed(self, subtask):
|
||||
return subtask['is_completed']
|
||||
|
||||
def subtask_is_completed_yes(self, subtask):
|
||||
if self.subtask_is_completed(subtask):
|
||||
return True
|
||||
return False
|
||||
|
||||
def subtask_is_completed_no(self, subtask):
|
||||
if not self.subtask_is_completed(subtask):
|
||||
return True
|
||||
return False
|
||||
|
||||
def delete_subtask(self, subtask, is_completed=None):
|
||||
if is_completed is not None:
|
||||
if self.subtask_is_completed(subtask) != is_completed:
|
||||
return None
|
||||
project_id = subtask['project_id']
|
||||
task_id = subtask['task_id']
|
||||
subtask_id = subtask['id']
|
||||
@@ -81,6 +97,24 @@ class ACClient:
|
||||
(project_id, task_id),
|
||||
data=subtask)
|
||||
|
||||
# find subtask with matching body
|
||||
def find_subtask_with_body(self, task, body, is_completed=False):
|
||||
# FIXME: returns only the first match!
|
||||
for subtask in task['subtasks']:
|
||||
if subtask['name'] == body:
|
||||
if is_completed is not None:
|
||||
if self.subtask_is_completed(subtask) == is_completed:
|
||||
return subtask
|
||||
return subtask
|
||||
return None
|
||||
|
||||
def delete_all_open_subtasks(self, task):
|
||||
return self.delete_all_subtasks(task, is_completed=False)
|
||||
|
||||
def delete_all_subtasks(self, task, is_completed=None):
|
||||
for subtask in task['subtasks']:
|
||||
self.delete_subtask(subtask, is_completed)
|
||||
|
||||
def unassign_all_sub_task(self, task):
|
||||
for subtask in task['subtasks']:
|
||||
self.unassign_sub_task(subtask)
|
||||
|
||||
Reference in New Issue
Block a user