def add_artwork(): new_artwork = ui.get_artwork_info() all_artworks = store.get_all_artworks() if new_artwork in all_artworks: ui.message('The artwork already exists') else: store.add_artwork(new_artwork) new_artwork = ui.get_artwork_info() new_artwork.save()
def main(): db_initialize() # basic menu I think, I'm not sure if I should've put validation here or elsewhere. menu_selection = '' while menu_selection.lower() != 'q': menu_selection = ui.display_menu() if menu_selection == '1': # selection 1 goes to the UI to get info from the user # then puts those together to add the artist, taking the response # and sending it to be displayed. artist_name = ui.get_artist_name() artist_email = ui.get_artist_email() response = add_artist((artist_name, artist_email)) ui.message(response) elif menu_selection == '2': # adding artwork does much the same, requests info and then attemps to add # if it's successful, the response gives an ok. artwork_data = ui.get_artwork_info() response = add_artwork(artwork_data) ui.message(response) elif menu_selection == '3': data = select_artists() ui.display_artists(data) elif menu_selection == '4': artist_id = ui.get_artist_id() data = select_artworks(artist_id) ui.display_artworks(data) # elif menu_selection == '5': ui.quit()
def add_artwork(): try: artist_name = ui.get_artist_name() artist_id = artwork_store._get_artist_id(artist_name) new_artwork = ui.get_artwork_info(artist_id) new_artwork.insert_artwork() except: print( '\nNo artist found with that name in the Artwork Store database. Please add this artist first.\n' )
def add_new_artwork(): artwork, artist = ui.get_artwork_info() artist_found = art_work.check_if_artist_exists(artist) try: if not artist_found: ui.failed('artist does not exist') else: new_artwork = Artwork(artist_found[0], artwork.artwork_name, artwork.price, artwork.availability) check_artwork = art_work.check_if_artwork_exists( artwork.artwork_name) if check_artwork is False: art_work.add_artwork(new_artwork) ui.confirmation('successfully added ' + artwork.artwork_name) else: ui.failed(artwork.artwork_name + ' has not been added') except Exception as e: print(e)
def add_artwork(): new_artwork = ui.get_artwork_info() try: new_artwork.save() except peewee.IntegrityError: ui.message('Error, artwork already exists in the database')
def delete_artwork(): delete_artwork = ui.get_artwork_info() delete_artwork.delete()
def artwork_price(): artwork_price = ui.get_artwork_info() artwork_price.save()
def artwork_name(): artwork_name = ui.get_artwork_info() try: artwork_name.save() except peewee.IntegrityError: ui.message('Error, artwork already exists in the database')