Beispiel #1
0
def add_new_artist():  # Create Add New Artist function
    # Prompt user for new artist's name
    new_artist_name = ui.get_non_empty_string(
        input("What is the name of the artist you would like to add? "))
    # Prompt user for new artist's e-mail address
    new_artist_email = ui.get_non_empty_string(
        input(
            "Please enter the e-mail address of the artist you would like to add: "
        ))
    # Update database with values
    db.add_new_artist(new_artist_name, new_artist_email)
Beispiel #2
0
def search_recipe():
    """get info about the user's choose food and drink from 3 different api.
        """
    search_recipe = ui.get_non_empty_string("Please Enter recipe name: ")
    search_drink = ui.get_non_empty_string("Please enter drink name: ")
    recipe_result = api_controller.get_food_info(search_recipe, search_drink)
    recipe_name, recipe_url, drink_name, img_file_name = recipe_result

    save = ui.save_or_not_save()
    if save:
        save_record(recipe_name, recipe_url, drink_name, img_file_name)
        ui.message('Your recipe has been saved. ')
    else:
        ui.message('Try searching again. \n')
Beispiel #3
0
def main():  # Create main function

    # While main function is active do the following ...
    while True:
        # Welcome and instruct the user
        print("Welcome to the Interactive Art Catolouge!\n")
        print(
            'Please select an option from the menu below: (Enter "Q" to Quit)')
        print(
            "1. Add Artist\n2. Add Artwork\n3. Search by Artist\n4. Delete Artwork\n5. Display Artist's Work\n6. Change Artwork Availablity\n7. Display Artist's Available Artwork\n"
        )

        option = ui.get_non_empty_string(input("Enter your desired option: "))

        # Explain user options
        if option == "1":
            add_new_artist()
        elif option == "2":
            add_new_artwork()
        elif option == "3":
            search_by_artist()
        elif option == "4":
            delete_artwork()
        # elif option == "5":
        # change_availability()
        elif option == "6":
            available_artwork()
        # Provide option for user to quit
        elif option == "q" or option == "Q":
            good_bye()
        break
Beispiel #4
0
def add_artwork():
    art_name = ui.get_non_empty_string("Enter the name of the art work? ")
    art_price = ui.get_positive_float("Enter the price of the art work? ")
    is_available = ui.get_availibility_value()
    artists_name = ui.get_non_empty_string("Enter name of artist ")
    artist = db_manager.check_if_artis_exist(artists_name)
    if artist:
        try:
            new_artwork = db_manager.create_art_work(artist, art_name,
                                                     art_price, is_available)
            new_artwork.save()
        except peewee.IntegrityError:
            ui.message(f" name: {art_name} already exists")
    else:
        ui.message(
            f"name: {artists_name}, doesn't exist in the database. Please create one first"
        )
Beispiel #5
0
def available_artwork():  # Create Available Artwork function
    # Prompt user for artist's name
    available_artist = ui.get_non_empty_string(
        input(
            "What is the name of the artist whose available artworks you want to see? "
        ))
    # Update database with values
    db.available_artwork(available_artist, )
Beispiel #6
0
def search_by_artist():  # Create Search by Artist function
    # Prompt user for artist name
    search_artist = ui.get_non_empty_string(
        input(
            "What is the name of the artist whose available artworks you want to see? "
        ))
    # Update database with values
    db.search_by_artist(search_artist, )
Beispiel #7
0
def add_artist():
    name = ui.get_non_empty_string("enter name ")
    email = ui.get_email()
    try:
        new_artist = db_manager.create_artist(name, email)
        new_artist.save()
    except peewee.IntegrityError:
        ui.message(
            f"Failed to add! Either the Name: {name}, or the Email: {email} already exist in the database "
        )
Beispiel #8
0
def search_by_artist():

    artist_name = ui.get_non_empty_string('Enter name of artist: ')

    artist_found = Artstore.search_for_artist(artist_name)

    if not artist_found:
        print('No artist with that name exists')
    else:
        artworks = Artstore.search_for_all_artwok(artist_found[0])
        ui.print_artworks(artworks)
Beispiel #9
0
def add_new_artwork():  # Create Add New Artwork function
    # Prompt user for new artworks's name
    new_artwork = ui.get_non_empty_string(
        input("What is the name of the artwork you would like to add? "))
    # Prompt user for new artwork's artist
    new_artist = ui.get_non_empty_string(
        input("What is the name of the artist attributed to that artwork? "))
    # Prompt user for new artwork's price
    new_price = ui.get_positive_float(
        float(input("How much does the artwork cost? $")))
    # Prompt user for new artwork's availability
    new_avaiability = ui.get_non_empty_string(
        input("Is the artwork currently available for purchase? Y/N: "))
    # Make yes True and no False
    if new_avaiability == "y" or "Y":
        True
    else:
        False
    # Update database with values
    db.add_new_artwork(new_artwork, new_artist, new_price, new_avaiability)
Beispiel #10
0
def delete_art():

    artwork_name = ui.get_non_empty_string('Enter artwork name that you want to delete: ')

    artwork_found = Artstore.search_for_artwork(artwork_name)

    if not artwork_found:
        print('No arwork with that name exists')
    else:
        confirm = ui.get_true_or_false('Are you sure you want to delete')
        if confirm:
            Artstore.delete_artwork(artwork_name)
            print(f'{artwork_name} has beed deleted')
Beispiel #11
0
def search_by_artist_available():

    artist_name = ui.get_non_empty_string('Enter name of artist: ')

    artist_found = Artstore.search_for_artist(artist_name)

    if not artist_found:
        print('No artist with that name exists')
    else:
        artworks = Artstore.search_for_all_artwok(artist_found[0])
        for art in artworks:
            if art[2] == 0:
                artworks.remove(art)
        
        ui.print_artworks(artworks)
Beispiel #12
0
def change_availability():
    try: 
        artwork_name = ui.get_non_empty_string('Enter artwork name that you want to change: ')

        artwork_found = Artstore.search_for_artwork(artwork_name)
        if not artwork_found:
            print('No artwork with that name exists')
        else:
            if artwork_found[2] == 0:
                Artstore.change_availability(1,artwork_name)
                print(f'\nAvailability of {artwork_name} changed to Available.')
            else:
                Artstore.change_availability(0,artwork_name)
                print(f'\nAvailability of {artwork_name} changed to Unavailable')
    except NameError:
        print('Artwork does not exist')
Beispiel #13
0
def show_all_artwork_by_one_artist():
    #this methods gets all artwork of one artist
    name = ui.get_non_empty_string(
        'enter the name of artist the one you want to see his/her arts')
    artstore.get_all_artwork_of_artist(name)
Beispiel #14
0
def delete_artwork():  # Create Delete Artwork function
    # Prompt user for artwork to be deleted
    deleted_artwork = ui.get_non_empty_string(
        input("What is the name of the artwork you would like to remove? "))
    # Update database with values
    db.delete_artwork(deleted_artwork, )
Beispiel #15
0
def add_artist():
    # get input
    name = ui.get_non_empty_string('Artist name? ')
    email = ui.get_non_empty_string('Artist email? ')
    email.add_artist(name, email)
Beispiel #16
0
def add_artwork():
    artName = ui.get_non_empty_string('\nName of artwork? ')
    artistName = ui.get_non_empty_string('Name of artist? ')
    artistName.add_artwork(artName, artistName)
Beispiel #17
0
def delete_artwork():
    artName = ui.get_non_empty_string('\nArtwork to delete? ')
    artName.delete_artwork(artName)