def delete_a_book(): """ Deletes a book """ del_book = ui.get_title() if datastore.delete_book_by_title(del_book): ui.message('Book deleted: ' + str(del_book)) else: ui.message('No Match Found for ' + str(del_book))
def edit_book_rating(): target_book_title = ui.get_title() if not datastore.check_for_book_existence_in_system(target_book_title): ui.message('No Match Found for Title: {}'.format(target_book_title)) else: target_book_rating = ui.get_rating_info() datastore.set_rating(target_book_title, target_book_rating)
def edit_read_date_by_title(updated_read_to_true=False, updated_title=None): target_title = updated_title if not updated_read_to_true: target_title = ui.get_title() if datastore.check_for_book_existence_in_system(target_title): if datastore.get_read_by_title(target_title): date_read = ui.get_date_read() datastore.set_date_read(target_title, date_read) datastore.set_read(target_title, set_to=False)
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')
def edit_book_title(): """ Edits a title of a book """ edit_book = ui.get_title() ui.message("New title: ") new_title = input("") datastore.edit_title(edit_book, new_title)
def search_book(): """ Searches for a book in the wishlist and read lists """ search_title = ui.get_title() search = datastore.search_books(search_title) ui.message('Book: ' + str(search))