Beispiel #1
0
def update(pet_id):
    owner = get_model_by_id('pet', pet_id)
    form = PetForm(request.form, ObjectView(owner))
    if request.method == 'POST' and form.validate():
        update_model('pet', pet_id, form.data)
        return redirect(url_for('pet.index'))
    return render_template('pet/update.html', form=form)
Beispiel #2
0
def update(admin_id):
    admin = get_model_by_id('admin', admin_id)
    form = AdminForm(request.form, ObjectView(admin))
    if request.method == 'POST' and form.validate():
        update_admin(admin_id, form.username.data, form.password.data)
        return redirect(url_for('admin.index'))
    return render_template('admin/update.html', form=form)
Beispiel #3
0
def update(booking_id):
    booking = get_model_by_id('booking', booking_id)
    form = BookingForm(request.form, ObjectView(booking))
    form.owner_id.choices = [(pet['id'],
                              f'{pet["last_name"]}, {pet["first_name"]}')
                             for pet in get_owners()]
    form.pet_id.choices = [(pet['id'], pet['name']) for pet in get_pets()]
    if request.method == 'POST' and form.validate():
        fields = form.data
        fields.pop('owner_id')
        update_model('booking', booking_id, fields)
        return redirect(url_for('booking.index'))
    return render_template('booking/update.html', form=form)
Beispiel #4
0
def delete(pet_id):
    pet = get_model_by_id('pet', pet_id)
    if pet is not None:
        delete_model('pet', pet_id)
    return redirect(url_for('pet.index'))
Beispiel #5
0
def delete(owner_id):
    owner = get_model_by_id('owner', owner_id)
    if owner is not None:
        delete_model('owner', owner_id)
    return redirect(url_for('owner.index'))
Beispiel #6
0
def delete(admin_id):
    admin = get_model_by_id('admin', admin_id)
    if admin is not None:
        delete_model('admin', admin_id)
    return redirect(url_for('admin.index'))
Beispiel #7
0
def delete(booking_id):
    booking = get_model_by_id('booking', booking_id)
    if booking is not None:
        delete_model('booking', booking_id)
    return redirect(url_for('booking.index'))