def edit_pet(id):
    pet = PetRep().select(id)
    vets = VetRep().select_all()
    return render_template('/pets/dashboard/details.html',
                           vets=vets,
                           title='Edit pet',
                           selected_page="update_pet",
                           pet=pet,
                           selected_dash_item='details')
def edit_pets(id):
    pets = VetRep().get_pets(id)
    all_pets_suboptimal = PetRep().select_all()
    # getting only the pets that this vet doesn't have
    vet_pet_ids = [pet.id for pet in pets]
    all_pet_ids = [pet.id for pet in all_pets_suboptimal]

    unique_pet_ids = list_diff(vet_pet_ids, all_pet_ids)
    all_pets = []
    for unique_id in unique_pet_ids:
        all_pets.append(PetRep().select(unique_id))

    vet = VetRep().select(id)
    return render_template('/vets/dashboard/see-pets.html',
                           all_pets=all_pets,
                           pets=pets,
                           title='Vet',
                           vet=vet,
                           selected_page='update_vet',
                           selected_dash_item='pets')
示例#3
0
    def select(self, id):
        pet = None
        sql = f"SELECT * FROM {self.table} " + "WHERE id = %s"
        values = [id]
        result = run_sql(sql, values)[0]

        if result is not None:
            owner = OwnerRep().select(result['owner_id'])
            vet = VetRep().select(result['vet_id'])
            pet = Pet(result["pet_name"], result["dob"], result["yo"],
                      result['animal_type'], owner, vet, result['img'],
                      result['img_type'], result['id'])
            pet.update_age()
        return pet
示例#4
0
    def select_all(self):
        pets = []
        sql = f"SELECT * FROM {self.table}"
        results = run_sql(sql)

        for row in results:
            owner = OwnerRep().select(row['owner_id'])
            vet = VetRep().select(row['vet_id'])
            pet = Pet(row["pet_name"], row["dob"], row["yo"],
                      row['animal_type'], owner, vet, row['img'],
                      row['img_type'], row['id'])
            pet.update_age()
            pets.append(pet)
        return pets
示例#5
0
def edit_pets_POST(owner_id, pet_id):
    
    # getting form data
    name = request.form.get('name')
    dob_string = request.form.get('dob')
    yo_string = request.form.get('yo')
    type_s = request.form.get('type')
    vet_id = request.form.get('vet')
    image = request.files['image']

    vet = VetRep().select(vet_id)
    owner = OwnerRep().select(owner_id)
    # date time logic
    if dob_string != '':
        dob = string_to_date(dob_string)
    else: 
        dob = False
    try:
        yo = float(yo_string.replace(',', '.'))
    except ValueError:
        yo = False
        
        

    # image logic
    new_image_string = False
    new_image_type = image.content_type
    if image.filename != '': # image was given
        new_image_string = base64.b64encode(image.read()).decode('utf-8')
        # write_to_file(new_image_string, new_image_type) 

    # if pet already has an image and an image was not given
    pet = PetRep().select(pet_id)
    if pet.image64 != '' and image.filename == '':
        new_image_string = pet.image64
        new_image_type = pet.image_type

    # if a new date was given in the form of yo and this is not a dash
    if yo and float(pet.yo) != float(yo):
        dob = False
    pet = Pet(name, dob, yo, type_s, owner, vet, new_image_string, new_image_type, pet_id)
    PetRep().update(pet)

    return redirect('/owners/'+owner_id+'/pets')
示例#6
0
def create_pet_POST(owner_id):
    
    # getting form data
    name = request.form.get('name')
    dob_string = request.form.get('dob')
    yo_string = request.form.get('yo')
    type_s = request.form.get('type')
    vet_id = request.form.get('vet')
    image = request.files['image']
    
    vet = VetRep().select(vet_id)
    owner = OwnerRep().select(owner_id)    
    
    # date time logic
    if dob_string != '':
        dob = string_to_date(dob_string)
        yo = False
    else: 
        dob = False
        try:
            yo = float(yo_string.replace(',', '.'))
        except ValueError:
            yo = False
            
    # image logic
    new_image_string = False
    new_image_type = image.content_type
    if image.filename != '': # image was given
        new_image_string = base64.b64encode(image.read()).decode('utf-8')
        # write_to_file(new_image_string, new_image_type) 

    pet = Pet(name, dob, yo, type_s, owner, vet, new_image_string, new_image_type)
    PetRep().save(pet)

    # owner = OwnerRep().select(owner_id)
    # pets = OwnerRep().get_pets(owner_id)
    return redirect('/owners/'+owner_id+'/pets')
示例#7
0
from repositories.testimonial_rep import TestimonialRep
from repositories.treatment_pet import PetTreatmentsRep
from repositories.treatment_rep import TreatmentRep
from repositories.vet_rep import VetRep
from repositories.visit_rep import VisitRep

from utils.read_file import read_file

VisitRep().delete_all()
FeedbackRep().delete_all()
TestimonialRep().delete_all()
PetTreatmentsRep().delete_all()
PetRep().delete_all()
OwnerRep().delete_all()
TreatmentRep().delete_all()
VetRep().delete_all()

# OWNERS
helen = Owner('Helen', 'Theo', '*****@*****.**', '+33 6972845697', True)
OwnerRep().save(helen)

maria = Owner('Maria', 'Jeyck', '*****@*****.**', '+33 6972849697', True)
maria_obj = OwnerRep().save(maria)

lola = Owner('Lola', 'Markelo', '*****@*****.**', '+33 6934449697', True)
lola_obj = OwnerRep().save(lola)

kost = Owner('Kost', 'Theo', '*****@*****.**', '+33 6945645697', True)
kost_obj = OwnerRep().save(kost)

evi = Owner('Evi', 'Prountz', '*****@*****.**', '+33 6972454337', True)
示例#8
0
def delete_vet(id):
    VetRep().delete(id)
    return redirect('/vets/all')
示例#9
0
def see_all_vets():
    vets = VetRep().select_all(True)
    return render_template('/vets/see-all.html', title = 'Vets', selected_page = "see_vets", vets = vets)
示例#10
0
def add_owner_POST():
    first_name = request.form.get('first_name')
    last_name = request.form.get('last_name')
    vet = Vet(first_name, last_name)
    VetRep().save(vet)
    return redirect('/vets/all')
示例#11
0
def create_pet_GET(id):
    owner = OwnerRep().select(id)
    vets = VetRep().select_all()
    return render_template('/owners/dashboard/add-pet.html', vets = vets, title = 'Owner', selected_page = 'update_owner', owner = owner, selected_dash_item = 'pets')
示例#12
0
def edit_pets(id):
    owner = OwnerRep().select(id)
    pets = OwnerRep().get_pets(id)
    vets = VetRep().select_all()
    return render_template('/owners/dashboard/see-pets.html', pets = pets, title = 'Owner', vets=vets, selected_page = 'update_owner', owner = owner, selected_dash_item = 'pets')
示例#13
0
def edit_vet(id):
    vet = VetRep().select(id)
    return render_template('/vets/dashboard/details.html', title = 'Edit Vet', selected_page = "update_vet", vet = vet, selected_dash_item = 'details')
示例#14
0
def edit_vet_POST(id):
    fist_name = request.form.get('first_name')
    last_name = request.form.get('last_name')
    VetRep().update(fist_name, last_name, id)
    vet = VetRep().select(id)
    return render_template('/vets/dashboard/details.html', title = 'Edit Vet', selected_page = "update_vet", vet = vet, selected_dash_item = 'details')