def create_shelters(session): """Function to create Shelter objects.""" shelter_1 = get_or_create(session, Shelter, name="Oakland Animal Services", address="1101 29th Ave", city="Oakland", state="California", zip_code="94601", website="oaklandanimalservices.org") shelter_2 = get_or_create(session, Shelter, name="San Francisco SPCA Mission "\ "Adoption Center", address="250 Florida St", city="San Francisco", state="California", zip_code="94103", website="sfspca.org") shelter_3 = get_or_create(session, Shelter, name="Wonder Dog Rescue", address="2926 16th Street", city="San Francisco", state="California", zip_code="94103", website="http://wonderdogrescue.org") shelter_4 = get_or_create(session, Shelter, name="Humane Society of Alameda", address="PO Box 1571", city="Alameda", state="California", zip_code="94501", website="hsalameda.org") shelter_5 = get_or_create(session, Shelter, name="Palo Alto Humane Society", address="1149 Chestnut St.", city="Menlo Park", state="California", zip_code="94025", website="paloaltohumane.org") ALL_SHELTERS.extend( [shelter_1, shelter_2, shelter_3, shelter_4, shelter_5] )
def create_all_the_things(session): """Function to create Shelter and Puppy objects.""" create_shelters(session) for i, rand_name in enumerate(MALE_NAMES): rand_shelter_id = randint(0, 4) new_puppy = get_or_create(session, Puppy, name=rand_name, gender="Male", date_of_birth=create_random_age(), picture=random.choice(PUPPY_IMAGES), shelter_id=rand_shelter_id, shelter=ALL_SHELTERS[rand_shelter_id], weight=create_random_weight()) for i, rand_name in enumerate(FEMALE_NAMES): rand_shelter_id = randint(0, 4) new_puppy = get_or_create(session, Puppy, name=rand_name, gender="Female", date_of_birth=create_random_age(), picture=random.choice(PUPPY_IMAGES), shelter_id=rand_shelter_id, shelter=ALL_SHELTERS[rand_shelter_id], weight=create_random_weight())