def update_todo_plan_date(self, todo, planned_date): """Set the planning date for a task, selected by natural language.""" selected_todo = self.match_todo_by_string(todo)['todo'] parsed_date = parse_datetime(planned_date) print "Change do-date of '%s' to %s?" % (selected_todo['text'], pretty.date(parsed_date)) if confirm(resp=True): selected_todo.set_planning_date(parsed_date, update=True)
def delete_todo(self, *todos): """Delete a task.""" todo_string = " ".join(todos) selected_todo = self.match_todo_by_string(todo_string)['todo'] print "Delete '%s'?" % selected_todo['text'] if confirm(resp=True): selected_todo.delete()
def add_checklist_item(self, check, parent_str): """Add a checklist item to a todo matched by natural language.""" selected_todo = self.match_todo_by_string(parent_str) if not selected_todo: print "No match found." else: parent = selected_todo['todo'] print parent['text'] if confirm(resp=True): if 'checklist' not in parent.keys(): parent['checklist'] = [] parent['checklist'].append({'text': check, 'completed': False}) parent.update_db() print self.get_todo_str(parent, completed_faint=True)
def complete_todo(self, *todos): """Complete a task selected by natural language with a confirmation.""" todo_string = " ".join(todos) selected_todo = self.match_todo_by_string(todo_string) print selected_todo['todo']['text'] if confirm(resp=True): # If it has a parent, it is a checklist item parent = selected_todo['parent'] if parent: # Mark the checklist item as complete and repost check_index = selected_todo['check_index'] parent['checklist'][check_index]['completed'] = True parent.update_db() # Print the remaining sections of the task print self.get_todo_str(parent, completed_faint=True) # Otherwise it is a normal to-do else: selected_todo['todo'].complete() self._print_change(selected_todo['todo'])