def link(self, first_id, second_id): """Make link between two tasks by their task ID""" self.load_tasks_from_json() first_index = utils.get_task_index(first_id, self) second_index = utils.get_task_index(second_id, self) self.tasks[first_index].connection.append(second_id) self.tasks[second_index].connection.append(first_id) self.resave()
def edit(self, tid, **kwargs): self.load_tasks_from_json() index = utils.get_task_index(tid, self) title = kwargs.get('title') if title is not None: self.tasks[index].title = title description = kwargs.get('description') if description is not None: self.tasks[index].description = description priority = kwargs.get('priority') if priority is not None: self.tasks[index].priority = Priority[priority] tag = kwargs.get('tag') if tag is not None: self.tasks[index].tag = Tag(tag) end = kwargs.get('end') if end is not None: self.tasks[index].end = utils.str_to_date(end) self.resave()
def delete(self, tid): self.load_tasks_from_json() if len(self.tasks) == 0: raise IndexError("Nothing to delete") index = utils.get_task_index(tid, self) del self.tasks[index] self.resave()
def begin_task(self, tid): self.load_tasks_from_json() index = utils.get_task_index(tid, self) self.tasks[index].begin() self.resave()
def uncomplete_task(self, tid): self.load_tasks_from_json() index = utils.get_task_index(tid, self) self.tasks[index].undone() self.resave()