def adopterAdd(): if request.method == 'POST': newItem = Adopter(name = request.form['name']) newItem.email = request.form['email'] newItem.mailing_id = request.form['mailing_id'] session.add(newItem) session.commit() flash("New adopter has been added.") return redirect(url_for('adopterList')) else: return render_template('adopteradd.html')
def newAdopter(): if request.method == 'POST': newAdopter = Adopter(name=request.form['name']) session.add(newAdopter) session.commit() flash("New Adopter created!") return redirect(url_for("viewAdopter", key=newAdopter.id)) else: return render_template('new.html', viewType="adopter", traits=Adopter.defaultTraits())
def newAdopter(): if request.method == 'POST': newAdopter = Adopter( name = request.form['name'] ) session.add(newAdopter) session.commit() flash("New Adopter created!") return redirect( url_for("viewAdopter", key = newAdopter.id) ) else: return render_template( 'new.html', viewType = "adopter", traits = Adopter.defaultTraits() )
def populate(self): #Add Shelters shelter1 = Shelter(name="Oakland Animal Services", address="1101 29th Ave", city="Oakland", state="California", zipCode="94601", website="oaklandanimalservices.org", maximum_capacity=randint(25, 35)) session.add(shelter1) shelter2 = Shelter(name="San Francisco SPCA Mission Adoption Center", address="250 Florida St", city="San Francisco", state="California", zipCode="94103", website="sfspca.org", maximum_capacity=randint(25, 35)) session.add(shelter2) shelter3 = Shelter(name="Wonder Dog Rescue", address="2926 16th Street", city="San Francisco", state="California", zipCode="94103", website="http://wonderdogrescue.org", maximum_capacity=randint(25, 35)) session.add(shelter3) shelter4 = Shelter(name="Humane Society of Alameda", address="PO Box 1571", city="Alameda", state="California", zipCode="94501", website="hsalameda.org", maximum_capacity=randint(25, 35)) session.add(shelter4) shelter5 = Shelter(name="Palo Alto Humane Society", address="1149 Chestnut St.", city="Menlo Park", state="California", zipCode="94025", website="paloaltohumane.org", maximum_capacity=randint(25, 35)) session.add(shelter5) session.commit() self.shelters.extend( [shelter1, shelter2, shelter3, shelter4, shelter5]) # Add Adopters a_name = random.choice(adopter_names) adopter1 = Adopter(name=random.choice(adopter_names)) removeAdopterName(a_name) session.add(adopter1) a_name = random.choice(adopter_names) adopter2 = Adopter(name=random.choice(adopter_names)) removeAdopterName(a_name) session.add(adopter2) a_name = random.choice(adopter_names) adopter3 = Adopter(name=random.choice(adopter_names)) removeAdopterName(a_name) session.add(adopter3) a_name = random.choice(adopter_names) adopter4 = Adopter(name=random.choice(adopter_names)) removeAdopterName(a_name) session.add(adopter4) a_name = random.choice(adopter_names) adopter5 = Adopter(name=random.choice(adopter_names)) removeAdopterName(a_name) session.add(adopter5) session.commit() self.adopters.extend( [adopter1, adopter2, adopter3, adopter4, adopter5]) #Add Puppies print "Before Males: %s" % self.numShelters() for i, x in enumerate(male_names): new_profile = CreateProfile(x, "male") session.add(new_profile) shelter_id = self.CheckinPuppy() new_puppy = Puppy(shelter_id=shelter_id, profile=new_profile) new_puppy.adopters.append(self.ChooseAdopter()) session.add(new_puppy) session.commit() print "Before Females: %s" % self.numShelters() for i, x in enumerate(female_names): new_profile = CreateProfile(x, "female") session.add(new_profile) shelter_id = self.CheckinPuppy() new_puppy = Puppy(shelter_id=shelter_id, profile=new_profile) new_puppy.adopters.append(self.ChooseAdopter()) session.add(new_puppy) session.commit()
session = Session(bind=engine) n = 35 session.add_all([ Organization("P. Sherman, 42 Wallaby Way, Sydney", "555-555-5555", random.uniform(0, 100), "User %d" % i, "Sydney Animal Rescue Center", "123-_password_-321") for i in range(n) ]) session.commit() session.add_all([ Adopter("User %d" % i, "123-_password_-321", "Energetic", "A large apartment building", 13, 18) for i in range(n) ]) session.commit() session.add_all([ Animals("In good health. Vaccinated, tagged, and spayed/neutered", 4, "Lazy", "Garfield", "1", "static/Garfield.png", "Tabby", "Cat", "Orange", "6") for i in range(n) ]) session.commit() session.add_all( [Employee("User %d" % i, "123-_password_-321", "1") for i in range(n)])