Пример #1
0
def del_puppy():
    form = DelForm()
    if form.validate_on_submit():
        id = form.id.data
        del_id = Puppy_Project.query.get(ident=id)
        db.session.delete(del_id)
        db.session.commit()
        return redirect(location=url_for(endpoint = 'puppies.list_pup'))
    return render_template(template_name_or_list= 'delete.html', form = form)
Пример #2
0
def delete():
    form = DelForm()
    if form.validate_on_submit():
        id = form.id.data
        pup = Puppy.query.get(id)
        db.session.delete(pup)
        db.session.commit()
        return redirect(url_for('puppies.list'))
    return render_template('delete.html', form=form)
Пример #3
0
def del_pup():
	form=DelForm() #Instance of the form

	if form.validate_on_submit():
		id=form.id.data
		pup=Puppy.query.get(id)
		db.session.delete(pup)
		db.session.commit()

		flash('Record Deleted Successfully!')
		return redirect(url_for('puppies.list_pup'))
	return render_template('delete.html',form=form)
Пример #4
0
def delete():
    form = DelForm()
    if form.validate_on_submit():

        id = form.id.data
        pup = Puppy.query.get(id)
        # flash(
        #     f"Puppy_Id: {pup.id} Name: {pup.name} has been removed from the database!")

        db.session.delete(pup)
        db.session.commit()

        return redirect(url_for('puppies.list'))
    return render_template('delete.html', form=form)
Пример #5
0
def delete():
    form = DelForm()

    if form.validate_on_submit():
        pup_id = form.id.data

        pup = Puppy.query.get(pup_id)
        flash(
            f'{pup.name} has been adopted, so it\'s no longer in our database')

        db.session.delete(pup)
        db.session.commit()

        return redirect(url_for('puppies.delete'))

    return render_template('delete.html', form=form)
Пример #6
0
def delete():

    form = DelForm()
    not_id_mess = ''
    if form.validate_on_submit():
        id = form.id.data

        pup_for_del = Puppy.query.get(id)
        if pup_for_del:
            db.session.delete(pup_for_del)
            db.session.commit()
            return redirect(url_for('puppies.list'))
        else:
            not_id_mess = f'Sorry, but we do not have the puppy with id: {id} '
            return render_template('delete.html',
                                   form=form,
                                   not_id_mess=not_id_mess)

    return render_template('delete.html', form=form, not_id_mess=not_id_mess)