Exemplo n.º 1
0
def puppyView(puppy_id):
    puppy = models.selectAllPuppies().filter_by(puppy_id=puppy_id)
    owner = models.selectAdopterOwners(puppy_id)
    shelter = models.selectEnrolledShelter(puppy_id)
    a = models.selectAdopterOwners(puppy_id).scalar()
    for p in puppy:
        print p.picture
    if a is None:
        txt1 = 'Adopt'
        txt2 = ''
        btn = 'success'
        att = 'enabled'
    else:
        txt1 = ''
        txt2 = 'was already adopted'
        btn = 'danger'
        att = 'disabled'
    return render_template('puppyView.html',
                           puppy=puppy,
                           puppy_id=puppy_id,
                           shelter=shelter,
                           owner=owner,
                           txt1=txt1,
                           txt2=txt2,
                           att=att,
                           btn=btn)
Exemplo n.º 2
0
def puppyEdit(puppy_id):
    if 'username' not in login_session:
        return render_template('unauthorized.html')
    else:
        shelter_choices = models.selectAvailableShelters()
        form = forms.PuppyForm(request.form, obj=shelter_choices)
        form.shelter_id.choices = [(a.shelter_id, a.name)
                                   for a in shelter_choices]
        puppy = models.selectAllPuppies().filter_by(puppy_id=puppy_id)
        shelter = models.selectEnrolledShelter(puppy_id)
        if request.method == "POST" and form.validate():
            edit_puppy = {
                'name': form.name.data,
                'gender': form.gender.data,
                'dateOfbirth': form.dateOfbirth.data,
                'picture': form.picture.data,
                'breed': form.breed.data,
                'weight': form.weight.data,
                'shelter_id': form.shelter_id.data
            }
            models.editPuppy(edit_puppy, puppy_id)
            return redirect(url_for('puppies'))
        else:
            return render_template('puppyEdit.html',
                                   puppy=puppy,
                                   puppy_id=puppy_id,
                                   shelter=shelter,
                                   form=form)
Exemplo n.º 3
0
def puppyView(puppy_id):
    puppy = models.selectAllPuppies().filter_by(puppy_id = puppy_id)
    owner = models.selectAdopterOwners(puppy_id)
    shelter = models.selectEnrolledShelter(puppy_id)
    a = models.selectAdopterOwners(puppy_id).scalar()
    for p in puppy:
        print p.picture
    if a is None:
        txt1 = 'Adopt'
        txt2 = ''
        btn = 'success'
        att = 'enabled'
    else:
        txt1 = ''
        txt2 = 'was already adopted'
        btn = 'danger'
        att = 'disabled'
    return render_template('puppyView.html', 
        puppy = puppy, 
        puppy_id = puppy_id, 
        shelter = shelter, 
        owner = owner, 
        txt1 = txt1,
        txt2 = txt2,
        att = att, 
        btn = btn)
Exemplo n.º 4
0
def puppyEdit(puppy_id):
    if 'username' not in login_session:
        return render_template('unauthorized.html')
    else:
        shelter_choices = models.selectAvailableShelters()
        form = forms.PuppyForm(request.form, obj = shelter_choices)
        form.shelter_id.choices = [(a.shelter_id, a.name) for a in shelter_choices]
        puppy = models.selectAllPuppies().filter_by(puppy_id=puppy_id)
        shelter = models.selectEnrolledShelter(puppy_id)
        if request.method == "POST" and form.validate():
            edit_puppy = {
                'name': form.name.data,
                'gender': form.gender.data,
                'dateOfbirth': form.dateOfbirth.data,
                'picture': form.picture.data,
                'breed': form.breed.data,
                'weight': form.weight.data,
                'shelter_id': form.shelter_id.data}
            models.editPuppy(edit_puppy, puppy_id)
            return redirect(url_for('puppies'))
        else:
            return render_template('puppyEdit.html', 
                puppy = puppy, 
                puppy_id = puppy_id, 
                shelter = shelter,
                form = form)
Exemplo n.º 5
0
def puppyDelete(puppy_id):
    if 'username' not in login_session:
        return render_template('unauthorized.html')
    else:
        puppy = models.selectAllPuppies().filter_by(puppy_id=puppy_id)
        if request.method == "POST":
            models.deletePuppy(puppy_id)
            return redirect(url_for('puppies'))
        else:
            return render_template('puppyDelete.html',
                                   puppy=puppy,
                                   puppy_id=puppy_id)
Exemplo n.º 6
0
def puppyDelete(puppy_id):
    if 'username' not in login_session:
        return render_template('unauthorized.html')
    else:
        puppy = models.selectAllPuppies().filter_by(puppy_id=puppy_id)
        if request.method == "POST":
            models.deletePuppy(puppy_id)
            return redirect(url_for('puppies'))
        else:
            return render_template('puppyDelete.html', 
                puppy = puppy, 
                puppy_id = puppy_id)
Exemplo n.º 7
0
def ownerView(owner_id):
    puppy = models.selectAllPuppies().filter_by(owner_id=owner_id)
    owner = models.selectAllOwners().filter_by(owner_id=owner_id)
    try:
        a = puppy.scalar()
        if a is None:
            pups = "No puppies adopted yet!"
        else:
            pups = "Adopted Puppies:"
    except:
        pups = "Adopted Puppies:"
    print pups
    return render_template("ownerView.html", owner_id=owner_id, owner=owner, puppy=puppy, pups=pups)
Exemplo n.º 8
0
def ownerView(owner_id):
    puppy = models.selectAllPuppies().filter_by(owner_id=owner_id)
    owner = models.selectAllOwners().filter_by(owner_id=owner_id)
    try:
        a = puppy.scalar()
        if a is None:
            pups = "No puppies adopted yet!"
        else:
            pups = "Adopted Puppies:"
    except:
        pups = "Adopted Puppies:"
    print pups
    return render_template('ownerView.html',
                           owner_id=owner_id,
                           owner=owner,
                           puppy=puppy,
                           pups=pups)
Exemplo n.º 9
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)
Exemplo n.º 10
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)