def update(id):
    date = request.form["date"]
    entry = request.form["entry"]
    animal = animal_repository.select(request.form["animal_id"])
    record = Record(date, entry, animal, id)
    record_repository.update(record)
    return redirect(f"/records/{id}")
示例#2
0
def create():
    description = request.form['description']
    animal_id = request.form['animal']
    animal = animal_repository.select(animal_id)
    new_note = Medical(description, animal)
    medical_repository.save(new_note)
    return redirect("/medicals")
def edit_animal(id):
    animal = animal_repository.select(id)
    customers = customer_repository.select_all()
    return render_template("/animals/edit.html",
                           title="Edit Animal",
                           animal=animal,
                           all_customers=customers)
def update(id):
    description = request.form["description"]
    days = request.form["duration_days"]
    hours = request.form["duration_hours"]
    minutes = request.form["duration_minutes"]
    duration = dh.time_delta(f"{days}:{hours}:{minutes}:00")

    days = request.form["recovery_days"]
    hours = request.form["recovery_hours"]
    minutes = request.form["recovery_minutes"]
    recovery = dh.time_delta(f"{days}:{hours}:{minutes}:00")

    cost = int(float(request.form["cost"]) * 100)
    animal = animal_repository.select(request.form["animal_id"])
    old_treatment = treatment_repository.select(animal)
    animal.owner.decrease_bill(old_treatment.cost)
    treatment = Treatment(description, duration, recovery, cost, animal, id)
    if "start" in request.form:
        treatment.start_treatment()
    else:
        start = treatment_repository.select(animal).start
        treatment.start_treatment(start)
    animal.owner.increase_bill(treatment.cost)
    owner_repository.update(animal.owner)
    treatment_repository.update(treatment)
    return redirect(f"/animals/{animal.id}")
def create():
    date = request.form["date"]
    entry = request.form["entry"]
    animal = animal_repository.select(request.form["animal_id"])
    record = Record(date, entry, animal)
    record_repository.save(record)
    return redirect(f"/animals/{request.form['animal_id']}")
示例#6
0
def create():
    allergy_id = request.form['allergy']
    animal_id = request.form['animal']
    allergy = allergy_repository.select(allergy_id)
    animal = animal_repository.select(animal_id)
    new_animal_allergy = AnimalAllergy(animal, allergy)
    animalallergy_repository.save(new_animal_allergy)
    return redirect("/allergys")
示例#7
0
def edit_animal(id):
    animal = animal_repository.select(id)
    owners = owner_repository.select_all()
    vets = vet_repository.select_all()
    return render_template('animals/edit.html',
                           animal=animal,
                           all_owners=owners,
                           all_vets=vets)
示例#8
0
def delete_from_source(id, source):
    treatment = treatment_repository.select(id)
    if source == "vet":
        source_id = vet_repository.select(treatment.vet.id).id
    elif source == "animal":
        source_id = animal_repository.select(treatment.animal.id).id
    treatment_repository.delete(id)
    return redirect(f'/{source}s/{source_id}')
def show_owners(id):
    animals = animal_repository.select(id)
    owner = owner_repository.select(id)
    owned_animals = animal_repository.display_animals_owned(id)
    return render_template("owners/show.html",
                           owner=owner,
                           owned_animals=owned_animals,
                           animals=animals)
def select(id):
    sql = "SELECT * FROM treatments WHERE id=%s"
    values = [id]
    result = run_sql(sql, values)[0]
    vet = vet_repository.select(result['vet_id'])
    animal = animal_repository.select(result['animal_id'])
    treatment = Treatment(animal, vet, result['details'], result['date'], id)
    return treatment
def get_info_for_update(id):
    animal = animal_repository.select(id)
    vets = vet_repository.select_all()
    owners = owner_repository.select_all()
    return render_template('/animals/edit.html',
                           animal=animal,
                           vets=vets,
                           owners=owners,
                           title=f"Update {animal.name}")
def create_appointment():
    start_time = request.form["start_time"]
    end_time = request.form["end_time"]
    appointment_date = request.form["appointment_date"]
    animal = animal_repository.select(request.form["animal_id"])
    new_appointment = Appointment(start_time, end_time, appointment_date,
                                  animal)
    appointment_repository.save(new_appointment)
    return redirect("/appointments")
示例#13
0
def select(id):
    record = None
    sql = "SELECT * FROM records WHERE id = %s"
    values = [id]
    row = run_sql(sql, values)[0]
    if row is not None:
        animal = animal_repository.select(row["animal_id"])
        record = Record(row["date"], row["entry"], animal, row["id"])
    return record
示例#14
0
def select_all():
    records = []
    sql = "SELECT * FROM records"
    results = run_sql(sql)
    for row in results:
        animal = animal_repository.select(row["animal_id"])
        record = Record(row["date"], row["entry"], animal, row["id"])
        records.append(record)
    return records
示例#15
0
def new(animal_id):
    animal = animal_repository.select(animal_id)
    dh = DateHelper()
    current_time = dh.print_datetime_local(datetime.datetime.now())
    return render_template(
        "records/new.html",
        title="New Record",
        animal=animal,
        current_time=current_time,
    )
示例#16
0
def select_all():
    aallergy = []
    sql = "SELECT * FROM animal_allergies"
    results = run_sql(sql)
    for row in results:
        animal = animal_repository.select(row['owner_id'])
        allergy = allergy_repository.select(row['vet_id'])
        animalallergy = AnimalAllergy(row[animal], row[allergy])
        aallergy.append(animalallergy)
    return aallergy
示例#17
0
def create_new_treatment():
    animal_id = request.form['animal_id']
    animal = animal_repository.select(animal_id)
    vet_id = request.form['vet_id']
    vet = vet_repository.select(vet_id)
    date = request.form['date']
    details = request.form['details']
    new_treatment = Treatment(animal, vet, details, date)
    treatment_repository.save(new_treatment)
    return redirect(f'/animals/{animal_id}')
示例#18
0
def select(id):
    aallergy = None
    sql = "SELECT * FROM animal_allergies WHERE id = %s"
    values = [id]
    result = run_sql(sql, values)[0]
    if result is not None:
        animal = animal_repository.select(result['owner_id'])
        allergy = allergy_repository.select(result['vet_id'])
        animalallergy = AnimalAllergy(result[animal], result[allergy])
        aallergy.append(animalallergy)
    return aallergy
def edit(animal_id):
    animal = animal_repository.select(animal_id)
    treatment = treatment_repository.select(animal)
    duration = dh.list_delta(treatment.duration)
    recovery = dh.list_delta(treatment.recovery)
    return render_template(
        "treatments/edit.html",
        title="Edit Treatment",
        treatment=treatment,
        duration=duration,
        recovery=recovery,
    )
def select_all():
    treatments = []
    sql = "SELECT * FROM treatments"
    results = run_sql(sql)

    for row in results:
        vet = vet_repository.select(row['vet_id'])
        animal = animal_repository.select(row['animal_id'])
        treatment = Treatment(animal, vet, row['details'], row['date'],
                              row['id'])
        treatments.append(treatment)

    return treatments
示例#21
0
def treatments(id):
    treatments = []
    sql = "SELECT * FROM treatments WHERE animal_id=%s"
    values = [id]
    results = run_sql(sql, values)

    for row in results:
        vet = vet_repository.select(row['vet_id'])
        animal = animal_repository.select(row['animal_id'])
        treatment = Treatment(animal, vet, row['details'], row['date'], row['id'])
        treatments.append(treatment)

    return treatments
示例#22
0
def select(id):
    sql = "SELECT * FROM appointments WHERE id = %s"
    vaules = [id]
    result = run_sql(sql, vaules)[0]
    animal = animal_repository.select(result["animal_id"])
        
    if result is not None:
        appointment = Appointment(
        result["start_time"], 
        result["end_time"],
        result["appointment_date"], 
        animal, 
        result["id"]) 
    return appointment
示例#23
0
def show(id):
    animal = animal_repository.select(id)
    treatment = treatment_repository.select(animal)
    animal.where(treatment)
    if not animal.checked_in and treatment is not None:
        treatment_repository.delete(treatment.id)
        treatment = None
    records = record_repository.records_by_animal(animal)
    return render_template(
        "animals/show.html",
        title="Animal",
        animal=animal,
        records=records,
        treatment=treatment,
    )
示例#24
0
def edit(id):
    animal = animal_repository.select(id)
    vets = vet_repository.select_all()
    for vet in vets:
        count = animal_repository.assigned_to(vet)
        vet.set_count(count)
        if vet.animal_count >= vet.max_animals and animal.vet.id is not vet.id:
            vet.set_busy()
        else:
            vet.set_available()
    return render_template(
        "animals/edit.html",
        title="Edit Animal",
        animal=animal,
        # owners=owners,
        vets=vets,
    )
示例#25
0
def select_all():
    appointments = []
    
    sql = "SELECT * FROM appointments"
    results = run_sql(sql)
    
    for result in results:
        animal = animal_repository.select(result["animal_id"])
        
        appointment = Appointment(
            result["start_time"], 
            result["end_time"],
            result["appointment_date"], 
            animal, 
            result["id"])
        appointments.append(appointment)
    return appointments
示例#26
0
def update_treatment(id):
    animal_id = request.form['animal_id']
    animal = animal_repository.select(animal_id)
    vet_id = request.form['vet_id']
    vet = vet_repository.select(vet_id)
    date = request.form['date']
    details = request.form['details']

    source = request.form['source']
    if source == "vet":
        source_id = vet.id
    elif source == "animal":
        source_id = animal.id

    updated_treatment = Treatment(animal, vet, details, date, id)
    treatment_repository.update(updated_treatment)
    return redirect(f'/{source}s/{source_id}')
def show(id):
    animal = animal_repository.select(id)
    treatments = animal_repository.treatments(id)
    date_today = datetime.datetime.now()
    treatments_future = [
        treatment for treatment in treatments
        if treatment.date >= date_today.date()
    ]
    treatments_past = [
        treatment for treatment in treatments
        if treatment.date < date_today.date()
    ]
    return render_template('/animals/show.html',
                           animal=animal,
                           treatments_future=treatments_future,
                           treatments_past=treatments_past,
                           title=animal.name)
def select_all():
    treatments = []
    sql = "SELECT * FROM treatments"
    results = run_sql(sql)
    for row in results:
        animal = animal_repository.select(row["animal_id"])
        treatment = Treatment(
            row["decription"],
            row["duration"],
            row["recovery"],
            row["cost"],
            animal,
            row["id"],
        )
        treatment.start = row["start"]
        treatments.append(treatment)
    return treatments
示例#29
0
def edit_animal(id):
    animal = animal_repository.select(id)
    owners = owner_repository.select_all()
    return render_template("/animals/edit.html",
                           all_owners=owners,
                           animal=animal)
示例#30
0
def get_animal(id):
    animal = animal_repository.select(id)
    return render_template("/animals/show.html", animal=animal)