Exemplo n.º 1
0
		return render_template('deletepuppy.html',shelter_id=shelter_id,puppy_id = puppy_id,puppy_name = puppy.name, shelter_name = shelter.name)

    

@app.route('/shelters/<int:shelter_id>/puppies/<int:puppy_id>/adopt/',methods=['GET','POST'])
def adoptPuppy(shelter_id, puppy_id):
	puppy = session.query(Puppy).filter_by(id = puppy_id).one()
	shelter = session.query(Shelter).filter_by(id = shelter_id).one()
	owner_list = session.query(Owner).all()
	if request.method == 'POST':
		new_owners = request.form.getlist('possible_owner')
		if new_owners:
			adopter_list = []
			for o_id in new_owners:
				o = session.query(Owner).filter_by(id = o_id).one()
				puppy.owners.append(o)
				adopter_list.append(str(o.name))
			shelter.current_occupancy -= 1
			session.add(shelter)
			session.add(puppy)
			session.commit()
			flash("Puppy {0} Adopted to {1}".format(puppy.name, adopter_list))
		return redirect(url_for('viewOneShelter',shelter_id=shelter_id))
	else:
		return render_template('adoptpuppy.html',shelter_id=shelter_id,puppy_id = puppy_id,puppy = puppy, owner_list = owner_list)

if __name__ == '__main__':
    app.secret_key = 'super_secret_key' # gives us access to the session to flash messages
    app.debug = True
    app.run(host='0.0.0.0', port=5000)
Exemplo n.º 2
0
from puppyadopter import app
app.secret_key = 'super_secret_key'
app.run(host='0.0.0.0', port=8910, debug=True)