def owner(): form = AddOwnerForm() if form.validate_on_submit(): name = form.name.data pup_id = form.puppy_id.data is_puppy = Puppy.query.filter_by(id=pup_id).first() if not is_puppy: flash( 'There is no such id number associated with a puppy. Please choose different one.' ) return redirect(url_for('owner')) else: owner_check = Owner.query.filter_by(puppy_id=pup_id).first() if owner_check: flash( f'Sorry, but this puppy is already adopted by {owner_check.name}' ) return redirect(url_for('owner')) owner = Owner(name, pup_id) db.session.add(owner) db.session.commit() return redirect(url_for('list_puppy')) return render_template('owner.html', form=form)
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): name = form.name.data pup_id = form.pup_id.data new_owner = Owner(name, pup_id) db.session.add(new_owner) db.session.commit() return redirect(url_for('list_pup'))
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): puppy = Puppy.query.get(form.puppy_id.data) new_owner = Owner(form.name.data, puppy.id) db.session.add(new_owner) db.session.commit() return redirect(url_for('list_pup')) return render_template('add_owner.html', form=form)
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): name = form.name.data pup_id = form.pup_id.data new_owner = Owner(name, pup_id) db.session.add(new_owner) db.session.commit() return redirect(url_for("list_pup")) return render_template("add_owner.html", form = form)
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): owner_name = form.owner.data cat_id = form.cat_id.data cur_owner = Owner(owner_name, cat_id) db.session.add(cur_owner) db.session.commit() return redirect(url_for('list')) return render_template('add_owner.html', form=form)
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): name = form.name.data puppy_id = form.puppy_id.data new_owner = Owner(name=name, puppy_id=puppy_id) db.session.add(new_owner) db.session.commit() flash(f'You just added owner: {new_owner.name}') return redirect(url_for('add_owner')) return render_template('addOwner.html', form=form)
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): owner_name = form.owner_name.data pup_id = form.puppy_id.data if Puppy.query.get(pup_id): owner = Owner(owner_name, pup_id) db.session.add(owner) db.session.commit() return redirect(url_for('list_pup')) return render_template('add_owner.html', form=form)
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): name = form.name.data id = form.id.data owner = Owner(name, id) db.session.add(owner) db.session.commit() return redirect(url_for('list_pup')) return render_template('owner.html', form=form)
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): pupid = form.id.data owner = form.owner.data newowner = Owner(owner, pupid) db.session.add(newowner) db.session.commit() return redirect(url_for('list_pup')) return render_template('owners.html', form=form)
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): name = form.name.data phone = form.phone.data email = form.email.data dog_id = form.dog_id.data new_owner = Owner(name, phone, email, dog_id) db.session.add(new_owner) db.session.commit() return redirect(url_for('list_dog')) return render_template('add_owner.html', form=form)
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): name = form.name.data pup_id = form.pup_id.data # Add new owner to database new_owner = Owner(name, pup_id) db.session.add(new_owner) db.session.commit() return redirect(url_for('list_pup')) return render_template('add_owner.html', form=form)
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): name = form.name.data kit_id = form.kit_id.data new_owner = Owner(name, kit_id) db.session.add(new_owner) db.session.commit() return redirect(url_for('list_kit')) return render_template('add_owner.html', form=form)
def add_own(): form = AddOwnerForm() if form.validate_on_submit(): name = form.name.data puppy_id = form.puppy_id.data # Add new Puppy to database new_owner = Owner(name, puppy_id) db.session.add(new_owner) db.session.commit() flash(f'The owner {new_owner.name} was added successfully') return redirect(url_for('list_pup')) return render_template('add_owner.html', form=form)
def add_owner(): # instantiate AddOwnerForm class. form = AddOwnerForm() if form.validate_on_submit(): id = form.pup_id.data # puppy = Puppy.query.get(id) name = form.name.data new_owner = Owner(name, id) db.session.add(new_owner) db.session.commit() return redirect(url_for('list_puppy')) return render_template('add_owner.html', form=form)
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): name = form.name.data puppy_id = form.puppy_id.data # Add new Owner to database new_owner = Owner(name, puppy_id) db.session.add(new_owner) db.session.commit() flash(f"You just added an owner with the name {new_owner.name} !") return redirect(url_for('list_pup')) return render_template('add_owner.html', form=form)
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): name = form.name.data puppy_id = form.puppy_id.data pup = Puppy.query.get(puppy_id) pup_name = pup.name owner = Owner(name, puppy_id) db.session.add(owner) db.session.commit() flash( f'Thanks for adopting {pup_name.capitalize()}, {owner.name.capitalize()}!' ) return redirect(url_for('list_pup')) return render_template('add_owner.html', form=form)
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): new_owner = Owner(name=form.name.data, puppy_id=form.puppy_id.data, address=form.address.data, city=form.city.data, state=form.state.data, phone=form.phone.data) sql = ( f"Insert into owners (name, puppy_id, address, city, state, phone) " f"values ('{form.name.data}', '{form.puppy_id.data}', '{form.address.data}', '{form.city.data}', " f"'{form.state.data}', '{form.phone.data}');") db.engine.execute(sql) return redirect(url_for('list_pup')) else: return render_template('add_owner.html', form=form)
def add_owner(): form = AddOwnerForm() if form.validate_on_submit(): id_puppy = form.id_puppy.data owner = form.owner.data if owner != "" and id_puppy != "": puppy = Puppy.query.get(id_puppy) if puppy != None and puppy.owner == None: owner = Owner(owner, id_puppy) db.session.add(owner) db.session.commit() return redirect(url_for('list_pups')) else: return render_template( "error.html", error="Puppy id you provided is not valid") else: return render_template( "error.html", error="Please enter owner's name and puppy id.") return render_template("addOwner.html", form=form)