예제 #1
0
def create_new_owner():
    name = request.form['name']
    contact = request.form['contact']
    postal_address = request.form['address']
    new_Owner = Owner(name, contact, postal_address, 0)
    owner_repository.save(new_Owner)
    return redirect("/owners")
예제 #2
0
def save():
    # Get data from request
    first_name = request.form['owner_first_name']
    last_name = request.form['owner_last_name']
    email = request.form['owner_email']
    contact_no = request.form['owner_contact_number']
    address = request.form['owner_address']
    post_code = request.form['owner_post_code']
    city = request.form['owner_city']

    if len(first_name) > 48:
        return_error('ao-1') # Return error code 1: Firstname too long
    elif len(last_name) > 48:
        return_error('ao-2') # Return error code 2: Lastname too long
    elif len(email) > 100:
        return_error('ao-3') # Return error code 3: Email address too long
    elif len(contact_no) > 11:
        return_error('ao-4') # Return error code 4: Contact number too long
    elif len(address) > 100:
        return_error('ao-5') # Return error code 5: Address too long
    elif len(post_code) > 8:
        return_error('ao-6') # Return error code 6: Post code too long
    elif len(city) > 100:
        return_error('ao-7') # Return error code 7: City too long

    # Create new owner object to be saved
    owner = Owner(first_name, last_name, email, contact_no, address, post_code, city, True)
    OR.save(owner)

    return redirect('/owners')
def create_owner():
    first_name = request.form['first_name']
    last_name = request.form['last_name']
    phone_num_1 = request.form['phone_num_1']
    phone_num_2 = request.form['phone_num_2']
    address = request.form['address']
    owner = Owner(first_name, last_name, phone_num_1, phone_num_2, address,
                  id)  # not sure here..
    owner_repository.save(owner)
    return redirect('/owners')
예제 #4
0
def create():
    first_name = request.form["first_name"]
    last_name = request.form["last_name"]
    num = request.form["num"]
    street = request.form["street"]
    city = request.form["city"]
    postcode = request.form["postcode"]
    address = Address(num, street, city, postcode)
    address_repository.save(address)
    tel = request.form["tel"]
    email = request.form["email"]
    owner = Owner(first_name, last_name, address, tel, email)
    owner_repository.save(owner)
    return redirect("/owners")
def new():
    if request.method == 'GET':
        return render_template("owners/new.html.j2")
    if request.method == 'POST':
        name = request.form['name']
        address = request.form['address']
        deactivated = False
        if name != "":
            owner = Owner(name, address, deactivated)
            saved_owner = owner_repository.save(owner)
            if saved_owner.id != None:
                message = f"Success {saved_owner.name} added"
            else:
                message = "Failure"
            if request.form['action'] == "finish":
                return redirect(url_for("owners.index", message=message))
            elif request.form['action'] == "continue":
                return render_template("owners/new.html.j2", message=message)
        else:
            return redirect(url_for("owner.index"))
    else:
        print("POST Error 405 Method Not Allowed")
예제 #6
0
import pdb
from models.owner import Owner
from models.animal import Animal
import repositories.owner_repository as owner_repository
import repositories.animal_repository as animal_repository

owner_1 = Owner("Craig", "Alexander")
owner_2 = Owner("David", "Strain")
animal_1 = Animal("Kass", 15, "Dog", owner_2)
animal_2 = Animal("Tila", 16, "Cat", owner_1)
owner_repository.save(owner_1)
owner_repository.save(owner_2)
animal_repository.save(animal_1)
animal_repository.save(animal_2)
예제 #7
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()
test_treat_clipclaw = Treatment(1, 1, "15/06/2020", "Clipped claws", 5)
test_treat_wormtabs = Treatment(2, 3, "01/02/2020", "Given worming tablets", 4)
test_treat_checkup = Treatment(3, 3, "29/12/2019", "Regular checkup", 3)
test_treat_4 = Treatment(4, 2, "15/11/2019", "Broken arm", 5)
test_treat_5 = Treatment(4, 2, "15/11/2019", "Dental surgeries", 3)
test_treat_6 = Treatment(4, 2, "15/11/2019", "Tooth Extraction", 8)
test_treat_7 = Treatment(4, 1, "15/11/2019", "Neutering", 9)
test_treat_8 = Treatment(4, 2, "15/11/2019", "Skin Surgeries", 6)
# --------

# save three 3 vets
vet_repository.save(test_vet_sam)
vet_repository.save(test_vet_joe)
vet_repository.save(test_vet_alison)
# save 4 owners
owner_repository.save(test_owner_david)
owner_repository.save(test_owner_peter)
owner_repository.save(test_owner_jamie)
owner_repository.save(test_owner_sarah)

# save 7 animals
animal_repository.save(test_animal_big_bird)
animal_repository.save(test_animal_earnie)
animal_repository.save(test_animal_brian)
animal_repository.save(test_animal_evil_monkey)
animal_repository.save(test_animal_buster)
animal_repository.save(test_animal_izzy)
animal_repository.save(test_animal_vinny)
animal_repository.save(test_animal_apollo)

# create some treatments
예제 #9
0
pet_type_2 = PetType('Dog', 'Boarder Collie')
PTR.save(pet_type_2)

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

pet_type_4 = PetType('Horse', 'Clydesdale')
PTR.save(pet_type_4)

pet_type_5 = PetType('Lizard', 'Geko')
PTR.save(pet_type_5)

# Owners
owner_1 = Owner('Ben', 'Davidson', '*****@*****.**', 1234567890,
                '1 Example Drive', 'AB1 2AB', 'Glasgow', True)
OR.save(owner_1)

owner_2 = Owner('Jane', 'Doe', '*****@*****.**', 1234567890,
                '1 Example Drive', 'AB1 2AB', 'Glasgow', True)
OR.save(owner_2)

owner_3 = Owner('John', 'Doe', '*****@*****.**', 1234567890,
                '1 Example Drive', 'AB1 2AB', 'Glasgow', True)
OR.save(owner_3)

# Vets

vet_1 = Vet('John', 'Doe')
VR.save(vet_1)

vet_2 = Vet('Jane', 'Doe')
예제 #10
0
def create_owners():
    name = request.form["name"]
    address = request.form["address"]
    new_owner = Owner(name, address)
    owner_repository.save(new_owner)
    return redirect("/owners")