def new_adoptor(): SHELTERS = Shelter.query.all() error = None form = CreateAdoptor() if form.validate_on_submit(): newadoptor = Adoptors(name=form.name.data) db.session.add(newadoptor) db.session.commit() flash( '<strong>Just created</strong> a new adoptor named <u>%s</u>' % newadoptor.name, 'info') return redirect(url_for('adoptor_list')) return render_template('create_adoptor.html', form=form, error=error, SHELTERS=SHELTERS)
def edit_adoptor(adoptor_id): SHELTERS = Shelter.query.all() editadoptor = Adoptors.query.filter_by(id=adoptor_id).one() form = CreateAdoptor(obj=editadoptor) if form.validate_on_submit(): editadoptor.name = form.name.data db.session.add(editadoptor) db.session.commit() flash( '<strong>Successful</strong> edit of this adoptor who is now named <u>%s</u>' % editadoptor.name, 'info') return redirect(url_for('adoptor_list')) return render_template('edit_adoptor.html', editadoptor=editadoptor, form=form, SHELTERS=SHELTERS)
def index(): SHELTERS = Shelter.query.all() """ front page of site that lists all shelters""" shelter = Shelter.query.order_by(Shelter.current_capacity.desc()).all() error = None form = CreateAdoptor() if form.validate_on_submit(): newadoptor = Adoptors(name=form.name.data) db.session.add(newadoptor) db.session.commit() flash( '<strong>Just created</strong> a new adoptor named <u>%s</u>.<br>\ Go Checkout the shelter pages to adopt a puppy!' % newadoptor.name, 'info') return redirect(url_for('adoptor_list')) return render_template('index.html', shelter=shelter, SHELTERS=SHELTERS, form=form, error=error)