def start_module(): """ Starts this module and displays its menu. User can access default special features from here. User can go back to main menu from here. Returns: None """ menu = [ 'Show items by status', 'Add item', 'Enter task toggle mode', 'Remove task', 'Archive Tasks', 'show eisenhower table' ] user_input = None matrix = TodoMatrix() try: matrix.add_items_from_file('my_file.csv') except FileNotFoundError: print("Error: file with data no provided.") open('my_file.csv', 'w').close() while user_input != '0': handle_menu(menu) user_input = choose_option(matrix) matrix.archive_items() matrix.save_items_to_file('my_file.csv')
def menu(): ''' Display menu and user choice option to turn. Return: None ''' info = 'Welcome in Eisenhower matrix. What can I help you?' print(info) show_menu = ''' 1) choose a status and show TODO items 2) add new item with deadline and priority 3) mark TODO item by cross if it's done 4) undo marking a TODO item 5) remove a chosen TODO item 0) archive, save and exit ''' matrix = TodoMatrix() start = True while start is True: print(show_menu) user_option = input('Your choice: ') if user_option == '1': status = choose_status() print(matrix.get_quarter(status)) elif user_option == '2': add_new_item(matrix) elif user_option == '3': status = choose_status() quarter = matrix.get_quarter(status) mark_done(quarter) elif user_option == '4': status = choose_status() quarter = matrix.get_quarter(status) unmark_done(quarter) elif user_option == '5': status = choose_status() quarter = matrix.get_quarter(status) remove_item(quarter) elif user_option == '0': matrix.archive_items() save_todo(matrix) print('Good bye') start = False return start else: print('Error choice!')
def test_archive_items(self): matrix = TodoMatrix() title = 'test add_item function' date_urgent = datetime(2017, 6, 6) date_not_urgent = datetime(2017, 7, 24) matrix.add_item(title, date_urgent, True) matrix.add_item(title, date_urgent, False) matrix.add_item(title, date_not_urgent, True) matrix.add_item(title, date_not_urgent, False) matrix.todo_quarters['IU'].todo_items[0].mark() matrix.todo_quarters['IN'].todo_items[0].mark() matrix.todo_quarters['NU'].todo_items[0].mark() matrix.todo_quarters['NN'].todo_items[0].mark() matrix.archive_items() self.assertEqual(matrix.todo_quarters['IU'].todo_items, []) self.assertEqual(matrix.todo_quarters['IN'].todo_items, []) self.assertEqual(matrix.todo_quarters['NU'].todo_items, []) self.assertEqual(matrix.todo_quarters['NN'].todo_items, [])
def run(self): os.system('clear') matrix = TodoMatrix() matrix.add_items_from_file('todo.csv') while self.is_running: os.system('clear') print(matrix) self.display_menu() option = self.get_input('Enter choice of menu: ') if option == '1': title = self.get_input('Enter title of TODO item: ') deadline_year = self.get_input('Enter year of deadline: ') deadline_month = self.get_input('Enter month of deadline: ') deadline_day = self.get_input('Enter day of deadline: ') deadline = datetime(int(deadline_year), int(deadline_month), int(deadline_day)) is_important = self.get_input( 'Is the task important? True/False: ') if is_important == 'True': is_important = True elif is_important == 'False': is_important = False matrix.add_item(title, deadline, is_important) elif option == '2': quarter_choice = self.get_input( 'Choose quarter (IU/IN/NU/NN): ') item_choice = int( self.get_input( 'Choose number of item to mark as done: ')) - 1 quarter = matrix.todo_quarters[quarter_choice] item = quarter.todo_items[item_choice] item.mark() elif option == '3': quarter_choice = self.get_input( 'Choose quarter (IU/IN/NU/NN): ') item_choice = int( self.get_input( 'Choose number of item to unmark from done: ')) - 1 quarter = matrix.todo_quarters[quarter_choice] item = quarter.todo_items[item_choice] item.unmark() elif option == '4': quarter_choice = self.get_input( 'Choose quarter (IU/IN/NU/NN): ') item_choice = int( self.get_input('Choose number of item to remove: ')) - 1 quarter = matrix.todo_quarters[quarter_choice] quarter.remove_item(item_choice) # item = quarter.todo_items[item_choice] # item.unmark() elif option == '5': matrix.archive_items() elif option == '0': self.is_running = False matrix.archive_items() matrix.save_items_to_file('todo.csv')