Example #1
0
def feedbacks_GET(id):
    owner = OwnerRep().select(id)
    feedbacks = OwnerRep().get_feedbacks(id)
    return render_template('/owners/dashboard/feedbacks.html',
                           feedbacks=feedbacks,
                           title='Owner',
                           selected_page='update_owner',
                           owner=owner,
                           selected_dash_item='feedbacks')
def edit_owner_POST(id):
    email = request.form.get('email')
    phone = request.form.get('phone')
    registered = request.form.get('register')
    OwnerRep().update(email, phone, registered, id)
    owner = OwnerRep().select(id)
    return render_template('/owners/dashboard/edit.html',
                           title='Edit Owner',
                           selected_page="update_owner",
                           owner=owner,
                           selected_dash_item='details')
def edit_owner(id):
    owner = OwnerRep().select(id)
    return render_template('/owners/dashboard/edit.html',
                           title='Edit Owner',
                           selected_page="update_owner",
                           owner=owner,
                           selected_dash_item='details')
def add_owner_POST():
    first_name = request.form.get('first_name')
    last_name = request.form.get('last_name')
    email = request.form.get('email')
    phone = request.form.get('phone')
    register = request.form.get('register')
    owner = Owner(first_name, last_name, email, phone, register)
    OwnerRep().save(owner)
    return redirect('/owners/all')
Example #5
0
def feedback_POST(id):
    qos = int(request.form.get('qos'))
    fs = int(request.form.get('fs'))
    cf = int(request.form.get('cf'))
    recommend = request.form.get('recommend')
    suggestions = request.form.get('suggestions')
    other_comment = request.form.get('other_comment')
    owner = OwnerRep().select(id)
    feedback = Feedback(qos, fs, cf, recommend, suggestions, other_comment,
                        owner)
    FeedbackRep().save(feedback)
    return redirect('/owners/' + id + '/feedbacks')
    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
    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
    def select_all(self):
        testimonials = []
        sql = f"SELECT * FROM {self.table}"
        results = run_sql(sql)

        for row in results:
            owner = OwnerRep().select(row["owner_id"])
            testimonial = Testimonial(
                row["testimonial"],
                owner,
                row["id"],
            )
            testimonials.append(testimonial)
        return testimonials
    def select(self, id):
        testimonial = 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"])
            testimonial = Testimonial(
                result["testimonial"],
                owner,
                result["id"],
            )
        return testimonial
Example #10
0
    def get_pets(self, vet_id):
        pets = []
        sql = "SELECT * FROM pets WHERE vet_id = %s"
        values = [vet_id]
        results = run_sql(sql, values)

        for row in results:
            owner = OwnerRep().select(row['owner_id'])
            vet = self.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
Example #11
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')
Example #12
0
    def select(self, id):
        feedback = 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"])
            feedback = Feedback(
                result["qos"],
                result["fs"],
                result["cf"],
                result["recommend"],
                result["suggestions"],
                result["other_comment"],
                owner,
                result["id"],
            )
        return feedback
Example #13
0
    def select_all(self):
        feedbacks = []
        sql = f"SELECT * FROM {self.table}"
        results = run_sql(sql)

        for row in results:
            owner = OwnerRep().select(row["owner_id"])
            feedback = Feedback(
                row["qos"],
                row["fs"],
                row["cf"],
                row["recommend"],
                row["suggestions"],
                row["other_comment"],
                owner,
                row["id"],
            )
            feedbacks.append(feedback)
        return feedbacks
Example #14
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')
def see_all_owners():
    owners = OwnerRep().select_all(True)
    return render_template('/owners/see-all.html',
                           title='Owners',
                           selected_page="see_owners",
                           owners=owners)
Example #16
0
from repositories.feedback_rep import FeedbackRep
from repositories.pet_rep import PetRep
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)
def delete_owner(id):
    OwnerRep().delete(id)
    return redirect('/owners/all')
Example #18
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')
def testimonial_GET(id):
    owner = OwnerRep().select(id)
    testimonial = OwnerRep().get_testimonial(id)
    return render_template('/owners/dashboard/testimonial.html', testimonial = testimonial, title = 'Owner', selected_page = 'update_owner', owner = owner, selected_dash_item = 'testimonial')
def testimonial_POST(id):
    owner = OwnerRep().select(id)
    testimonial = request.form.get('testimonial')
    testimonial = Testimonial(testimonial, owner)
    TestimonialRep().save(testimonial)
    return redirect('/owners/'+id+'/testimonial')
Example #21
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')