예제 #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)
예제 #2
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)
예제 #3
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)
예제 #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)