def edit_task(task): """ Edit and update selected task """ print("*" * 25) print("Editing task:") print("*" * 25) print(task.title) print("*" * 25) print("New Values:") print("*" * 25) # Request updated values of task from user title = input("Title of the task: ") username = input("Username: "******"Date of the task") date = utils.get_date() time_spent = utils.get_time_spent() notes = input("Notes (Optional, you can leave this empty): ") task.title = title task.username = username task.date = date task.time_spent = time_spent task.notes = notes # Now save task to database task.save() print("Task updated")
def search_by_time_spent(self): """ search users task by time spent """ utils.clear_screen() print("Please enter time spent on task:\n") time_spent = utils.get_time_spent() return list( filter(lambda task: task.time_spent == time_spent, self.tasks))
def create_users_task(self): """ Get user input and create users task """ utils.clear_screen() print("Date of the task") date = utils.get_date() date = utils.convert_date_to_string(date) utils.clear_screen() title = input("Title of the task: ") utils.clear_screen() time_spent = utils.get_time_spent() utils.clear_screen() notes = input("Notes (Optional, you can leave this empty): ") utils.clear_screen() self.add_task(date, title, time_spent, notes) print("Task successfully logged.\n")
def search_by_time_spend(cls): """ Search for tasks by time spent """ utils.clear_screen() print("Please enter time spent on task:") total = 0 while total == 0: timespent = utils.get_time_spent( input("Time spent(rounded minutes): ")) tasks = Task.select().where(Task.time_spent == timespent) print("No results found... Please retry.") total = len(tasks) else: return { 'tasks': tasks, 'time_spent': timespent, }
def create_task(cls): """ Get user input and create users task """ utils.clear_screen() # Request data from user username = input("Enter your username: "******"Date of the task") date = utils.get_date() utils.clear_screen() title = input("Title of the task: ") utils.clear_screen() time_spent = utils.get_time_spent() utils.clear_screen() notes = input("Notes (Optional, you can leave this empty): ") utils.clear_screen() # Now create task Task.create(username=username, date=date, title=title, time_spent=time_spent, notes=notes) print("Task successfully logged.\n")
def edit_task(self, task): """ Edit and update selected task """ while True: print("*" * 25) print("Editing task:") print("*" * 25) print(task) print("*" * 25) print("New Values:") print("*" * 25) print("Date of the task") date = utils.get_date() date = utils.convert_date_to_string(date) title = input("Title of the task: ") time_spent = utils.get_time_spent() notes = input("Notes (Optional, you can leave this empty): ") task.date = date task.title = title task.time_spent = time_spent task.notes = notes print("Task updated") break
def test_get_time_spent(self): """ Test get time spent for invalid integers """ self.assertFalse(utils.get_time_spent("Hi")) self.assertTrue(utils.get_time_spent(15))