示例#1
0
def delete_shelter(shelter_id):
    """page to delete a puppy."""
    shelter = session.query(Shelter).filter_by(id=shelter_id).first()
    form = ShelterForm(request.form, shelter)
    if request.method == "POST":
        session.delete(shelter)
        session.commit()
        flash("Shelter '" + shelter.name + "' deleted. Auf Wiedersehen!")
        return redirect(url_for("show_shelters"))

    else:
        output = render_template("page_head.html", title="Delete a Shelter", form=form)
        output += render_template("delete_shelter.html", form=form)
        return output
示例#2
0
def delete_adopter(adopter_id):
    """page to delete a puppy."""
    adopter = session.query(Adopter).filter_by(id=adopter_id).first()
    form = AdopterForm( request.form, adopter )
    if request.method == "POST":
        session.delete(adopter)
        session.commit()
        flash( "Adopter '" + adopter.name + "' deleted. Auf Wiedersehen!")
        return redirect(url_for("show_adopters"))

    else:
        output = render_template( 'page_head.html',
                                  title = "Delete an Adopter",
                                  form = form )
        output += render_template( 'delete_adopter.html',
                                   form = form )
        return output
示例#3
0
def delete_puppy(shelter_id, puppy_id):
    """page to delete a puppy."""
    if request.method == "POST":
        delete_this_puppy = session.query(Puppy).filter_by(id = puppy_id).first()
        session.delete(delete_this_puppy)
        session.commit()
        flash( "item '" + delete_this_puppy.name + "' deleted. Auf Wiedersehen!")
        return redirect(url_for("show_puppies", shelter_id=shelter_id))

    else:
        output = render_template('page_head.html', title = "The Menu Manager", form = 0)
        puppy = session.query(Puppy).filter_by(id = puppy_id).first()
        if shelter_id == "n":
            shelter = session.query(Shelter).filter_by(id = puppy.shelter_id).first()
        else:
            shelter = session.query(Shelter).filter_by(id = shelter_id).first()
        output += render_template( 'delete_puppy.html',
                                   puppy = puppy,
                                   shelter = shelter )
        return output