def update_vet(id):
    first_name = request.form['first_name']
    last_name = request.form['last_name']
    license = request.form ['license']
    vet = Vet(first_name, last_name, license, id)
    vet_repository.update(vet)
    return redirect('/vets')
def update_vet(id):
    first_name = request.form['first_name']
    last_name = request.form['last_name']
    img_url = request.form['img_url'] if request.form['img_url'] else "static/images/no_img.jpg"
    updated_vet = Vet(first_name, last_name, img_url, id)
    vet_repository.update(updated_vet)
    return redirect(f'/vets/{updated_vet.id}')
def update_vet(id):
    first_name = request.form["first-name"]
    last_name = request.form["last-name"]
    job_title = request.form["job-title"]
    id = request.form["id"]
    vet = Vet(first_name, last_name, job_title, id)
    vet_repository.update(vet)
    return redirect("/vets")
Пример #4
0
def update(id):
    # vet = vet_repository.select(id)
    first_name = request.form["first_name"]
    last_name = request.form["last_name"]
    max_animals = request.form["max_animals"]
    vet = Vet(first_name, last_name, max_animals, id)
    vet_repository.update(vet)
    return redirect(f"/vets/{id}")
Пример #5
0
def update(id):
    # Grab data from request
    first_name = request.form['vet_first_name']
    last_name = request.form['vet_last_name']

    if len(first_name) > 48:
        return_error('ev-1')  # Return error code 1: First name too long
    elif len(last_name) > 48:
        return_error('ev-2')  # Return error code 2: Last name too long

    # Create new object to be saved
    vet = Vet(first_name, last_name, id)
    VR.update(vet)

    # Redirect the user
    return redirect('/vets/' + id)
def detail(action, id):
    vet = vet_repository.select_id(id)
    if request.method == 'GET':
        if action == "show":
            return render_template("vets/show.html.j2", vet=vet)
        elif action == "edit":
            return render_template("vets/edit.html.j2", vet=vet)
        else:
            message = "Error Malformed URL"
            return redirect(url_for("vets.index", message=message))
    if request.method == 'POST':
        if action == "delete":
            vet_repository.delete_id(request.form['id'])
            message = f"Vet: {vet.name} (id:{vet.id}) deleted"
            return redirect(url_for("vets.index", message=message))
        elif action == "edit":
            name = request.form['name']
            try:
                deactivated = request.form['deactivated']
                if len(animal_repository.select_all_by_vet_id(id)) > 0:
                    message = f"Vet: {vet.name} (id:{vet.id}) has animals assigned"
                    return redirect(url_for("vets.index", message=message))
            except:
                deactivated = False
            vet = Vet(name, deactivated, id)
            vet_repository.update(vet)
            message = f"Vet: {vet.name} (id:{vet.id}) updated"
            return redirect(url_for("vets.index", message=message))
        elif action == "deactivate":
            if len(animal_repository.select_all_by_vet_id(id)) == 0:
                vet = vet_repository.select_id(id)
                vet.deactivated = True
                vet_repository.update(vet)
                message = f"Vet: {vet.name} (id:{vet.id}) has been deactivated"
            else:
                message = f"Vet: {vet.name} (id:{vet.id}) has animals assigned, reassign these first"
            return redirect(url_for("vets.index", message=message))
        # elif action == "move_animals":
        #code to move all animals from one vet to another#
        else:
            message = "Error Malformed URL"
            return redirect(url_for("vets.index", message=message))
Пример #7
0
def update_vet(id):
    name = request.form['name']
    contact = request.form['contact']
    vet = Vet(name, contact, id)
    vet_repository.update(vet)
    return redirect("/employees")
treatment_repository.delete_all()
patient_repository.delete_all()
client_repository.delete_all()
vet_repository.delete_all()

# Vet Repo Tests
vet_1 = Vet("Lin", "McDonald", "Graduate Vet")
vet_2 = Vet("Sharon", "Perkins", "Practice Partner")
vet_1 = vet_repository.save(vet_1)
vet_2 = vet_repository.save(vet_2)
vet_list = vet_repository.select_all()
selected_vet = vet_repository.select(vet_list[0].id)
# vet_repository.delete(vet_list[1].id)
vet_1.first_name = "Mary"
vet_repository.update(vet_1)
vet_list = vet_repository.select_all()

# Client repo tests
client_1 = Client("James", "McBean", "07666666666",
                  "1 Baberton Mains Row, Edinburgh, EH12 1LS", True, vet_1)
client_2 = Client("Daniel", "Jackson", "07888888888",
                  "16 Duke Street, Glasgow, G5 2FH", False, vet_2)
client_1 = client_repository.save(client_1)
client_2 = client_repository.save(client_2)
client_list = client_repository.select_all()
selected_client = client_repository.select(vet_list[0].id)
# client_repository.delete(client_1.id)
client_1.first_name = "Jim"
client_repository.update(client_1)
client_list = client_repository.select_all()