def show_unread(): '''Fetch and show all unread books''' # getting all the unread books in the data store unread = datastore.get_books(read=False) # uses the ui program to print out the books or to say no books in list ui.show_list(unread)
def search_records(): '''Get choice from user and search records for that choice''' #ask for id p_id = ui.ask_for_person_id() records = datastore.search_db(p_id) ui.show_list(records)
def show_items(): '''Fetch and show all Merch Items''' #TODO:this might not work #merch_list is returned from query @ merch_orm #that list passed into ui's show_list() to make user friendly ui.show_list(merch_orm.merch_list())
def new_sale(): '''Get info from user, add new Sale''' #show list of merch items for user reference (they probably haven't memorized merch ID #'s) merch_list = merch_orm.merch_list() ui.show_list(merch_list) #show list of events for user reference (they probably haven't memorized event ID #'s) event_list = merch_orm.event_list() ui.show_event_list(event_list) new_sale = ui.get_new_sale_info() merch_orm.add_object_to_db('Sale', new_sale)
def merch_sale_records(): '''Get Merch ID # from user, then query for results''' #show list of merch items for user reference (they probably haven't memorized merch ID #'s) merch_list = merch_orm.merch_list() ui.show_list(merch_list) #get merch id from user id = ui.get_id() #TODO query db for sales information based on Merch ID # merch_orm.sales_by_merchID(id)
def search_book(): ''' Get search term from user, if keyword exists, append book, show search results ''' search_results = [] all_books = datastore.get_books() search_term = ui.get_search_term() for book in all_books: if search_term in book.title: search_results.append(book) elif search_term in book.author: search_results.append(book) ui.message("Here's what I found:") ui.show_list(search_results)
def search_book(): search_option, search_value = ui.search_by() if search_option == "id": search_book = datastore.get_books(id=search_value) elif search_option == "title": search_book = datastore.get_books(title=str(search_value)) elif search_option == "author": search_book = datastore.get_books(author=str(search_value)) elif search_option == "rating": search_book = datastore.get_books(rating=search_value) ui.show_list(search_book)
def sort_book(): '''Sort the books either by title or by author''' books_to_sort = datastore.get_books() sortBook = int(input('Enter the sort option. 1 = title, 2 = author: ')) while True: if (sortBook == 1): sorted_books = sorted(books_to_sort, key=lambda book: book.title) ui.show_list(sorted_books) break elif (sortBook == 2): sorted_books = sorted(books_to_sort, key=lambda book: book.author) ui.show_list(sorted_books) break else: sortBook = int( input('Enter the correct options (1 = title, 2 = author): '))
def sort_list(): '''sort the books''' allBooks = datastore.get_books() sortBooksByTitle = sorted(allBooks, key=lambda book: book.title) sortbooksByAuthor = sorted(allBooks, key=lambda book: book.author) sortBy = int(input('Enter 1 to sort by title and 2 to sort by auther: ')) while True: if (sortBy == 1): ui.show_list(sortBooksByTitle) break elif (sortBy == 2): ui.show_list(sortbooksByAuthor) break else: print('The entry was incorrect.') sortBy = int(input('Enter the correct options: '))
def merch_sale_records(): '''Get Merch ID # from user, then query for results''' #show list of merch items for user reference (they probably haven't memorized merch ID #'s) merch_list = merch_orm.merch_list() ui.show_list(merch_list) #show list of sales for user reference sales_list = merch_orm.sales_list() ui.show_sales_list(sales_list) #get merch id from user print( 'To get total sales for a specific Merch item, enter Merch ID below:') id = ui.get_id() #query db for sales information based on Merch ID # merch_orm.sales_by_merchID(id)
def show_read(): '''Fetch and show all read books, sorted as requested by user.''' read = datastore.get_books(read=True) preference = ui.get_sort_info('r') if preference == '1': ui.show_list(datastore.sort_list('title', read)) elif preference == '2': ui.show_list(datastore.sort_list('author', read)) elif preference == '3': ui.show_list(datastore.sort_list('rating', read)) elif preference == '4': ui.show_list(read)
def show_unread(): '''Fetch and show all unread books, sorted as requested by user.''' unread = datastore.get_books(read=False) preference = ui.get_sort_info('n') if preference == '1': ui.show_list(datastore.sort_list('title', unread)) elif preference == '2': ui.show_list(datastore.sort_list('author', unread)) elif preference == '3': ui.show_list(unread)
def show_read(): '''Fetch and show all read books''' read = datastore.get_books(read=True) ui.show_list(read) if len(read) > 0: sort_choice = ui.display_sort_options() handle_sort_choice(sort_choice) if sort_choice == '1': s_list = sorted(read, key=s_author) ui.show_list(s_list) elif sort_choice == '2': s_list = sorted(read, key=s_title) ui.show_list(s_list)
def search_book(): """Fetch and show all read books""" search_string = input("Input the title or author of book: ") searched = datastore.get_books(string=search_string) ui.show_list(searched) pass
def search_book(): '''Get title from user. Show books with matching titles.''' book_title = ui.ask_for_book_title() found_books = datastore.search_books(book_title) ui.show_list(found_books)
def show_read(): """Fetch and show all read books""" read = datastore.get_books(read=True) ui.show_list(read)
def show_record(): '''Fetch and show all records''' records = datastore.get_records() ui.show_list(records)
def sort_by_title(): ''' Sort by book title ''' unread = datastore.get_sorted_books_by_title() ui.show_list(unread)
def sort_by_author(): ''' Sort by book author ''' unread = datastore.get_sorted_books_by_author() ui.show_list(unread)
def show_unread(): '''Fetch and show all unread books''' unread = datastore.get_books(read=False) ui.show_list(unread)
def show_items(): # merch_list is returned from query @ merch_orm # that list passed into ui's show_list() to make user friendly ui.show_list(merch_orm.merch_list())
def show_read(): '''Fetch and show all read books''' read = datastore.get_books(read=True) ui.show_list(read)
def search_book(): '''Fetch search books''' searchBooks = datastore.get_books(search=True) ui.show_list(searchBooks)