Exemplo n.º 1
0
def change_read():

    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)  
    new_read = ui.get_read_value()     
    book.read = new_read 
    book.save()
Exemplo n.º 2
0
def change_read():
    book_id = ui.get_book_id()
    new_read = ui.get_read_value()
    try:
        store.set_book_read(book_id, new_read)
        ui.message('Updated.')
    except BookError as e:
        ui.message(e)
Exemplo n.º 3
0
def change_read():

    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)  
    new_read = ui.get_read_value()     
    book.read = new_read 
    ui.message(f"You have {'read' if book.read else 'not read' } \"{book.title}\" by {book.author}")
    book.save()
Exemplo n.º 4
0
def change_read():
    try:
        book_id = ui.get_book_id()
        book = store.get_book_by_id(book_id)
        new_read = ui.get_read_value()
        book.read = new_read
        book.save()
    except:
        print('That book is not in the database!')
Exemplo n.º 5
0
def change_read():
    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)  
    new_read = ui.get_read_value()     
    book.read = new_read 
    book.save()
    if book.read:
        ui.message(f'You have read {book.title} by {book.author}')
    else:
        ui.message(f'You have not read {book.title} by {book.author}')

    
    if book: # book will be None if it's not found in db
        new_read = ui.get_read_value()     
        book.read = new_read 
        book.save()
    else:
        ui.message('Error: Book Not Found')
Exemplo n.º 6
0
def change_read():
    book_id = ui.get_book_id()
    try:
        book = store.get_book_by_id(book_id)
        new_read = ui.get_read_value()
        book.read = new_read
        book.save()
    except UnboundLocalError as e:
        ui.message('Book not found \n')
Exemplo n.º 7
0
def change_read():
    book_id = ui.get_book_id()
    book = bookstore.get_book_by_id(book_id)
    if not book:
        ui.message('Book not found')
        return
    new_read = ui.get_read_value()
    book.read = new_read
    book.save()
Exemplo n.º 8
0
def change_read():
    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)
    if book:
        new_read = ui.get_read_value()
        book.read = new_read
        book.save()
        ui.message(f'{book.title} by {book.author} has been updated!')
    else:
        ui.message(f'No book with ID {book_id} exists.')
Exemplo n.º 9
0
def change_read():
    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)
    new_read = ui.get_read_value()
    book.read = new_read
    if new_read:
        ui.message(f'\nConfirmation: You have read {book.title} by {book.author}\n')
    else:
        ui.message(f'\nConfirmation: You have not read {book.title} by {book.author}\n')
    book.save()
Exemplo n.º 10
0
def change_read():
    try:
        book_id = ui.get_book_id()
        book = store.get_book_by_id(book_id)
        new_read = ui.get_read_value()
        book.read = new_read
        book.save()
        print('It has been changed !')
    except:
        ui.message('Book not found')
Exemplo n.º 11
0
def change_read():
    try:
        book_id = ui.get_book_id()
        book = store.get_book_by_id(book_id)
        new_read = ui.get_read_value()
        book.read = new_read
        ui.message(f"You have {'read' if book.read else 'not read' } \"{book.title}\" by {book.author}")
        book.save()
    except:
        ui.message("A book with that ID does not exist in the database")    
Exemplo n.º 12
0
def change_read():

    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)
    if book != None:
        new_read = ui.get_read_value(book) #added book variable to be passed to be able to grab the book.title
        book.read = new_read
        book.save()
    else:
        print('No book with that ID. Please try again.')
Exemplo n.º 13
0
def change_read():

    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)
    # checking the object type
    if isinstance(book, Book):
        new_read = ui.get_read_value()
        book.read = new_read
        book.save()
    elif book == 'not found':
        create_menu()
Exemplo n.º 14
0
def change_read():
    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)
    if book:
        new_read = ui.get_read_value()
        book.read = new_read
        book.save()
        read_string = 'not ' if not book.read else ''
        print(f"\nYou have {read_string}read {book.title} by {book.author}\n")
    else:
        print(f'\nNo book with id: {book_id} found. Please try again.\n')
Exemplo n.º 15
0
def change_read():

    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)
    if book != None:
        new_read = ui.get_read_value()
        book.read = new_read
        book.save()
        ui.display_book_change_message(book)
    else:
        ui.message('Book does not exist, please select \'Add book\' instead.')
Exemplo n.º 16
0
def change_read():
    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)

    if book:
        new_read = ui.get_read_value()
        book.read = new_read
        read_status = 'have' if book.read else 'have not'
        ui.message(f'You {read_status} read {book.title} by {book.author}')
        book.save()
    else:
        print('Book not found')
Exemplo n.º 17
0
def change_read():
    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)
    if book != None:
        new_read = ui.get_read_value()
        book.read = new_read
        book.save()
        if new_read:
            read_status = 'READ'
        else:
            read_status = 'NOT READ'
        ui.message(f'Read status changed to {read_status}')
Exemplo n.º 18
0
def change_read():

    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)  

    #If the book value is none the error message is printed
    if book == None:  
        print('\nError: The book id is not in the database\n')
    else:
        new_read = ui.get_read_value()     
        book.read = new_read 
        book.save()
Exemplo n.º 19
0
def change_read():

    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)
    if book != None:
        new_read = ui.get_read_value()
        book.read = new_read
        book.save()
        if new_read == True:
            print("You have read ", book.title)
        else:
            print("You have not read ", book.title)
Exemplo n.º 20
0
def change_read():

    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)
    if book is not None:
        new_read = ui.get_read_value()
        book.read = new_read
        book.save()
        if new_read is False:
            print("You have not read " + book.title)
        else:
            print("You have read " + book.title + " by " + book.author)
Exemplo n.º 21
0
def change_read():
    """ gets book if then changes it to read or unread then saves it"""
    book_id = ui.get_book_id()  #gets book id
    book = store.get_book_by_id(book_id)  #checks to see if ID in the database
    if book is not None:
        new_read = ui.get_read_value(
            book
        )  #added book so book title and author is passed when confirmed
        book.read = new_read
        book.save()
    else:
        print('\nThe book ID you have entered is NOT in the database\n')
Exemplo n.º 22
0
def change_read():

    book_id = ui.get_book_id()

    book = store.get_book_by_id(book_id)
    #validation to check if the book exists
    if book == None:
        print('Book not found')
    else:
        new_read = ui.get_read_value()
        book.read = new_read
        book.save()
        print("you have changed the 'read or unread' status of this book. ")
Exemplo n.º 23
0
def change_read():
    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)
    if (book != "None"):
        new_read = ui.get_read_value()
        book.read = new_read
        if book.read == True:
            ui.message(f'You have read {book.title} by {book.author}.')
        else:
            ui.message(f'You have not read {book.title} by {book.author}.')

        book.save()
    else:
        ui.message("Book not found.")
Exemplo n.º 24
0
def change_read():
    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)

    if book is None:
        print("\n**Error: Book not found in database.**\n")
        return
    else:
        new_read = ui.get_read_value()

        if (new_read):
            print(f"\nYou have read {book.title} by {book.author}.\n")
        else:
            print(f"\nYou have not read {book.title} by {book.author}.\n")
        book.read = new_read
        book.save()
Exemplo n.º 25
0
def change_read():
    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)  
   
    if book:
        new_read = ui.get_read_value()     
        book.read = new_read 
        book.save()
        
        if new_read:
            print(f'You have read {book.title} by {book.author}')
            
        else:
            print(f'You have not read {book.title} by {book.author}')

    else:
        print('Error: book not found')
Exemplo n.º 26
0
def change_read():
    book_id = ui.get_book_id()
    book = store.get_book_by_id(book_id)
    if book:  # If book ID found in db
        new_read = ui.get_read_value()
        # if else statement to determine what the state the book is in
        if new_read == False:
            read_var = '"not read"'
        else:
            read_var = '"read"'
        book.read = new_read
        book.save()
        print('Book status has changed to', read_var)
    else:  # If book ID not found in db
        print('That book is not found.')
        option = input('Return to main menu? Y for main menu. ').upper()
        if option == 'Y':
            print()
        else:
            change_read()  # restarts function for book ID input
Exemplo n.º 27
0
 def test_get_read_value_validates(self, mock_input):
     self.assertTrue(ui.get_read_value())
Exemplo n.º 28
0
 def test_get_read_value_unread(self, mock_input):
     self.assertFalse(ui.get_read_value())
Exemplo n.º 29
0
def change_read():

    book_id = ui.get_book_id()
    new_read = ui.get_read_value()
    store.set_book_read(book_id, new_read)