Ejemplo n.º 1
0
def add_puppies():
    form = PuppiesForm()
    if form.validate_on_submit():
        current_puppies = Puppy(name=form.name.data,
                                age=form.age.data,
                                breed=form.breed.data)
        db.session.add(current_puppies)
        db.session.commit()
        flash('Your Puppies has been added!')
        return redirect(url_for('list_puppies'))
    return render_template('puppies/add_puppies.html', form=form, title='Add')
Ejemplo n.º 2
0
def edit_puppies(id):
    current_puppies = Puppy.query.get_or_404(id)
    form = PuppiesForm(name=current_puppies.name,
                       age=current_puppies.age,
                       breed=current_puppies.breed)
    if form.validate_on_submit():
        current_puppies.name = form.name.data
        current_puppies.age = form.age.data
        current_puppies.breed = form.breed.data
        db.session.add(current_puppies)
        db.session.commit()
        flash('Your Puppies has been updated!')
        return redirect(url_for('list_puppies'))
    return render_template('puppies/add_puppies.html', form=form, title='Edit')