Esempio n. 1
0
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()
Esempio n. 2
0
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'
        )
Esempio n. 3
0
def change_availability():
    artist_name = ui.get_artist_name()
    artist_id = artwork_store._get_artist_id(artist_name)
    artworks_list = artist_artwork.get_all_artist_artwork(artist_id)
    if artworks_list:  # If artwork ID found in db
        artwork_name = ui.get_artwork_name()
        artwork_to_change = artist_artwork.get_artwork_by_name(artwork_name)
        availability_status = ui.get_artwork_availability()
        # if else statement to determine if for sale or not
        if not availability_status:
            sale_status = '"Sold"'
        else:
            sale_status = '"For Sale"'
        artwork_to_change.for_sale = availability_status
        artwork_to_change.update_artwork()
        print('Artwork status has changed to', sale_status)
    else:  # If artwork ID not found in db
        print('That artist has no artworks.')
        option = input(
            'Return to main menu? Y for main menu or Enter to quit. ').upper()
        if option == 'Y':
            print()
        else:
            quit_program()
Esempio n. 4
0
def show_artist_available_artwork():
    artist_name = ui.get_artist_name()
    artist_id = artwork_store._get_artist_id(artist_name)
    artworks = Artwork.get_all_artist_available_artwork(artist_id)
    ui.show_artworks_by_artist(artworks)