Esempio n. 1
0
def settings():
    if request.method == 'GET':
        return render_template('settings.html.j2')
    if request.method == 'POST':
        if request.form['action'] == "delete_id":
            id = request.form['id']
            if request.form['table'] == "vet":
                vet = vet_repository.select_id(id)
                vet_repository.delete_id(id)
                message = f"Vet {vet.name} {vet.id} deleted, and cascaded"
            elif request.form['table'] == "owner":
                owner = owner_repository.select_id(id)
                owner_repository.delete_id(id)
                message = f"Owner {owner.name} {owner.id} deleted, and cascaded"
            elif request.form['table'] == "animal":
                animal = animal_repository.select_id(id)
                animal_repository.delete_id(id)
                message = f"Vet {animal.name} {animal.id} deleted, and cascaded"
        elif request.form['action'] == "delete_all":
            if request.form['table'] == "vet":
                vet_repository.delete_all()
                message = "All Vets deleted, and cascaded"
            elif request.form['table'] == "owner":
                owner_repository.delete_all()
                message = f"All Owners deleted, and cascaded"
            elif request.form['table'] == "animal":
                animal_repository.delete_all()
                message = f"All Animals deleted, and cascaded"
        return render_template('settings.html.j2', message=message)
Esempio n. 2
0
import pdb
from models.animal import *
from models.owner import *
from models.appointment import *

import repositories.owner_repository as owner_repository
import repositories.animal_repository as animal_repository
import repositories.appointment_repository as appointment_repository

owner_repository.delete_all()
animal_repository.delete_all()
appointment_repository.delete_all()

owner1 = Owner("Jimmy", "Cloverfeild")
owner_repository.save(owner1)
owner2 = Owner("Steve", "Black Mesa")
owner_repository.save(owner2)
# owner_repository.select_all()

animal1 = Animal("Joe", "2020-10-10", "Goose",
                 "Broken Goosing: Adminsiter 50cc's of goose.", owner1)
animal_repository.save(animal1)
# animal_repository.select_all()

appointment1 = Appointment("17:40", "2201-23-23", owner1, animal1)

appointment_repository.save(appointment1)
appointment_repository.select_all()

pdb.set_trace()
Esempio n. 3
0
from models.appointment import Appointment
import repositories.pet_type_repository as PTR
import repositories.owner_repository as OR
import repositories.pet_repository as PR
import repositories.note_repository as NR
import repositories.vet_repository as VR
import repositories.perscribed_treatments_repository as perscribed
import repositories.treatment_repository as TR
import repositories.appointment_repository as AR

# Drop the data from the tables
NR.delete_all()
PR.delete_all()
PTR.delete_all()
perscribed.delete_all()
OR.delete_all()
VR.delete_all()
TR.delete_all()

# Create data

# Pet Types
pet_type_1 = PetType('Dog', 'Spaniel')
PTR.save(pet_type_1)

pet_type_2 = PetType('Dog', 'Boarder Collie')
PTR.save(pet_type_2)

pet_type_3 = PetType('Cat', 'Scottish Fold')
PTR.save(pet_type_3)