Example #1
0
def edit_shelter(shelter_id, shelter_name):
    SHELTERS = Shelter.query.all()
    editshelter = Shelter.query.filter_by(id=shelter_id).one()
    form = CreateShelter(obj=editshelter)
    if form.validate_on_submit():
        editshelter.name = form.name.data
        editshelter.address = form.address.data
        editshelter.city = form.city.data
        editshelter.state = form.state.data
        editshelter.zipCode = form.zipCode.data
        editshelter.website = form.website.data
        editshelter.maximum_capacity = form.maximum_capacity.data
        editshelter.current_capacity = form.current_capacity.data
        db.session.add(editshelter)
        db.session.commit()
        counting_shows()
        flash("<strong>Update</strong>&nbsp; on <u>%s</u>." % editshelter.name, "info")
        return redirect(url_for("index"))
    return render_template("edit_shelter.html", editshelter=editshelter, form=form, SHELTERS=SHELTERS)
Example #2
0
def new_shelter():
    SHELTERS = Shelter.query.all()
    error = None
    form = CreateShelter()
    # form.state.choices = [(i.name,i.name) for i in us.states.STATES]
    if form.validate_on_submit():
        newshelter = 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,
            current_capacity=form.current_capacity.data,
        )
        db.session.add(newshelter)
        db.session.commit()
        flash("<strong>Congrats</strong> You just created a new shelter named <u>%s</u>." % newshelter.name, "warning")
        return redirect(url_for("index"))
    return render_template("create_shelter.html", form=form, error=error, SHELTERS=SHELTERS)
Example #3
0
def new_shelter():
    SHELTERS = Shelter.query.all()
    error = None
    form = CreateShelter()
    if form.validate_on_submit():
        newshelter = 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,
                             current_capacity=form.current_capacity.data
                             )
        db.session.add(newshelter)
        db.session.commit()
        flash("<strong>Congrats</strong> You just created a new shelter named <u>%s</u>." % newshelter.name, 'warning')
        return redirect(url_for('index'))
    return render_template('create_shelter.html', 
                            form=form, 
                            error=error,
                            SHELTERS=SHELTERS)
Example #4
0
def edit_shelter(shelter_id, shelter_name):
    SHELTERS = Shelter.query.all()
    editshelter = Shelter.query.filter_by(id=shelter_id).one()
    form = CreateShelter(obj=editshelter)
    if form.validate_on_submit():
        editshelter.name = form.name.data
        editshelter.address = form.address.data
        editshelter.city = form.city.data
        editshelter.state = form.state.data
        editshelter.zipCode = form.zipCode.data
        editshelter.website = form.website.data
        editshelter.maximum_capacity = form.maximum_capacity.data
        editshelter.current_capacity = form.current_capacity.data
        db.session.add(editshelter)
        db.session.commit()
        counting_shows()
        flash("<strong>Update</strong>&nbsp; on <u>%s</u>." % editshelter.name,
              'info')
        return redirect(url_for('index'))
    return render_template('edit_shelter.html',
                           editshelter=editshelter,
                           form=form,
                           SHELTERS=SHELTERS)
Example #5
0
def new_shelter():
    SHELTERS = Shelter.query.all()
    error = None
    form = CreateShelter()
    if form.validate_on_submit():
        newshelter = 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,
                             current_capacity=form.current_capacity.data)
        db.session.add(newshelter)
        db.session.commit()
        flash(
            "<strong>Congrats</strong> You just created a new shelter named <u>%s</u>."
            % newshelter.name, 'warning')
        return redirect(url_for('index'))
    return render_template('create_shelter.html',
                           form=form,
                           error=error,
                           SHELTERS=SHELTERS)