示例#1
0
def shelterDelete(shelter_id):
    if 'username' not in login_session:
        return render_template('unauthorized.html')
    else:
		shelter = models.selectAllShelters().filter_by(shelter_id=shelter_id)
		if request.method == "POST":
			models.deleteShelter(shelter_id)
			flash('A new shelter has been deleted!')
			return redirect(url_for('shelters'))
		else:
			return render_template('shelterDelete.html', shelter = shelter, shelter_id = shelter_id)
示例#2
0
def puppyAdopt(puppy_id):
    puppy = models.selectAllPuppies().filter_by(puppy_id=puppy_id)
    for pup in puppy:
        shelt = pup.shelter_id
    owners = models.selectAllOwners()
    shelters = models.selectAllShelters().filter_by(shelter_id=shelt)
    a = models.selectAdopterOwners(puppy_id).scalar()
    if a is None:
        txt1 = 'Adopt'
        txt2 = 'now!'
        btn = 'success'
        att = 'enabled'
    else:
        txt1 = ''
        txt2 = 'was already adopted'
        btn = 'danger'
        att = 'disabled'
    if request.method == "POST":
        dict_ownr = {'owner_id': request.form['owner_id']}
        print dict_ownr
        ownr = dict_ownr.get('owner_id')
        models.adoptPuppy(puppy_id, ownr, shelt)
        text = (
            'puppy_id(%s) was adopted from shelter_id(%s) by owner_id(%s)' %
            (puppy_id, ownr, shelt))
        logging.info = text
        text = text
        r = owners.filter_by(owner_id=ownr)
        for r in r:
            print r
        recipient = r.email
        email.email(text, recipient)
        return redirect(url_for('puppies'))
    else:
        return render_template('adoptPuppy.html',
                               puppy=puppy,
                               owners=owners,
                               shelters=shelters,
                               txt1=txt1,
                               txt2=txt2,
                               att=att,
                               btn=btn)
示例#3
0
def puppyAdopt(puppy_id):
	puppy = models.selectAllPuppies().filter_by(puppy_id=puppy_id)
	for pup in puppy:
		shelt = pup.shelter_id
	owners = models.selectAllOwners()
	shelters = models.selectAllShelters().filter_by(shelter_id=shelt)
	a = models.selectAdopterOwners(puppy_id).scalar()
	if a is None:
		txt1 = 'Adopt'
		txt2 = 'now!'
		btn = 'success'
		att = 'enabled'
	else:
		txt1 = ''
		txt2 = 'was already adopted'
		btn = 'danger'
		att = 'disabled'
	if request.method == "POST":
		dict_ownr = {'owner_id': request.form['owner_id']}
		print dict_ownr
		ownr = dict_ownr.get('owner_id')
		models.adoptPuppy(puppy_id, ownr, shelt)
		text = ('puppy_id(%s) was adopted from shelter_id(%s) by owner_id(%s)' % (puppy_id, ownr, shelt))
		logging.info = text
		text = text
		r = owners.filter_by(owner_id=ownr)
		for r in r:
			print r
		recipient = r.email
		email.email(text,recipient)
		return redirect(url_for('puppies'))
	else:
		return render_template('adoptPuppy.html', 
			puppy = puppy, 
			owners = owners, 
			shelters = shelters, 
			txt1 = txt1,
			txt2 = txt2,
			att = att, 
			btn = btn)
示例#4
0
def shelterEdit(shelter_id):
    if 'username' not in login_session:
        return render_template('unauthorized.html')
    else:
		form = forms.ShelterForm()
		shelter = models.selectAllShelters().filter_by(shelter_id=shelter_id)
		if request.method == "POST" and form.validate():
			edit_shelter = {
				'name': form.name.data,
				'address': form.address.data,
				'city': form.city.data,
				'state': form.state.data,
				'zipCode': form.zipCode.data,
				'website': form.website.data,
				'maximum_capacity': form.maximum_capacity.data}
			models.editShelter(edit_shelter, shelter_id)
			flash('A shelter has been edited!')
			return redirect(url_for('shelters'))
		else:
			return render_template('shelterEdit.html', 
				shelter_id = shelter_id, 
				shelter = shelter, 
				form = form)
示例#5
0
def shelters():
	shelters = models.selectAllShelters()
	return render_template('shelterAll.html', shelters = shelters)