Ejemplo n.º 1
0
def book_read():
    ''' Get choice from user, edit datastore, display success/error'''
    book_id = ui.ask_for_book_id()
    if datastore.set_read(book_id, True):
        ui.message('Successfully updated')
    else:
        ui.message('Book id not found in database')
Ejemplo n.º 2
0
def book_read():
    ''' Get choice from user, edit datastore, display success/error'''
    # uses ui to check and see if the book is in the system
    book_id = ui.ask_for_book_id()
    # if statment to give user feed back about results
    if datastore.set_read(book_id, True):
        ui.message('Successfully updated')
    else:
        ui.message('Book id not found in database')
Ejemplo n.º 3
0
def update_book_read():
    """ Get choice from user, edit datastore, display success/error"""

    book_title = ui.get_title()
    mark_as = ui.get_read_update_type()
    if datastore.set_read(book_title, mark_as):
        ui.message('Successfully updated')
        rating = ui.get_rating_info()  #todo move rating to own method
        datastore.set_rating(book_title, rating)
        if mark_as:
            edit_read_date_by_title(updated_read_to_true=True,
                                    updated_title=book_title)
    else:
        ui.message('Book id not found in database')
Ejemplo n.º 4
0
def book_read():
    ''' Get choice from user, edit datastore, display success/error'''
    book_id = ui.ask_for_book_id()
    rating = ''
    while rating not in range(1, 5):
        try:
            rating = int(input('Please enter a rating low (1) to high (5):'))
            if rating not in range(1, 5):
                ui.message('Rating is not in range, please try again')
        except ValueError:
            ui.message('Please enter a valid integer')

    rating = ('*' * rating)

    if datastore.set_read(book_id, True):
        ui.message('Successfully updated')
    else:
        ui.message('Book id not found in database')
Ejemplo n.º 5
0
def book_read():
    ''' Get choice from user, edit datastore, display success/error'''
    book_id = ui.ask_for_book_id()
    rating = ''
    while rating not in range(1, 5):
        try:
            rating = int(
                input("How many stars do you give this book? (1-5): "))
            if rating not in range(1, 5):
                print('Number not within valid range.')
        except ValueError:
            print('Please enter a valid integer')

    rating = ('*' * rating)

    if datastore.set_read(book_id, rating):
        ui.message('Successfully updated')
    else:
        ui.message('Book id not found in database')
Ejemplo n.º 6
0
def book_read():
    ''' Get choice from user, edit datastore, display success/error, get decision for re-read'''
    book_id = ui.ask_for_book_id()
    book_rating = ui.ask_for_book_rating()

    if datastore.set_read(book_id, book_rating):
        ui.message('Successfully updated')

        while True:
            againWish = input(
                "\nQuick Question..\nDo you want to add this book back into your wishlist for future reading? 'y'es or 'n'o "
            ).strip().lower()
            if againWish == "y":
                new_book()
                print("*Successfully Added to wishlist*\n")
                break

            elif againWish != "y":
                break
    else:
        ui.message('Book id not found in database')