Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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())
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
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)
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
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): '))
Ejemplo n.º 9
0
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: '))
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
0
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)
Ejemplo n.º 12
0
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)
Ejemplo n.º 13
0
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)
Ejemplo n.º 14
0
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
Ejemplo n.º 15
0
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)
Ejemplo n.º 16
0
def show_read():
    """Fetch and show all read books"""
    read = datastore.get_books(read=True)
    ui.show_list(read)
Ejemplo n.º 17
0
def show_record():
    '''Fetch and show all records'''
    records = datastore.get_records()
    ui.show_list(records)
Ejemplo n.º 18
0
def sort_by_title():
    ''' Sort by book title '''
    unread = datastore.get_sorted_books_by_title()
    ui.show_list(unread)
Ejemplo n.º 19
0
def sort_by_author():
    ''' Sort by book author '''
    unread = datastore.get_sorted_books_by_author()
    ui.show_list(unread)
Ejemplo n.º 20
0
def show_unread():
    '''Fetch and show all unread books'''
    unread = datastore.get_books(read=False)
    ui.show_list(unread)
Ejemplo n.º 21
0
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())
Ejemplo n.º 22
0
def show_read():
    '''Fetch and show all read books'''
    read = datastore.get_books(read=True)
    ui.show_list(read)
Ejemplo n.º 23
0
def search_book():
    '''Fetch search books'''
    searchBooks = datastore.get_books(search=True)
    ui.show_list(searchBooks)