def select(id):
    wizard = None
    sql = "SELECT * FROM wizards WHERE id = %s"
    values = [id]
    result = run_sql(sql, values)[0]

    if result is not None:
        wizard = Wizard(result['first_name'], result['last_name'], result['age'], result['id'] )
    return wizard
def select_all():
    wizards = []

    sql = "SELECT * FROM wizards"
    results = run_sql(sql)

    for row in results:
        wizard = Wizard(row['first_name'], row['last_name'], row['age'], row['id'] )
        wizards.append(wizard)
    return wizards
Esempio n. 3
0
def add_wizard():
    wizFirstName = request.form['first_name']
    wizLastName = request.form['last_name']
    wizAge = request.form['age']
    newWizard = Wizard(first_name=wizFirstName,
                       last_name=wizLastName,
                       age=wizAge)
    wiz_repo.save(newWizard)
    wizards = wiz_repo.select_all()
    return render_template('wizards/wizards.html',
                           title='Home',
                           wizards=wizards)
Esempio n. 4
0
 def setUp(self):
     self.wizard = Wizard("Norman", "Stargazer", 1000)
     self.item = Item("Hat", "Grey", "Standard; rounded point", self.wizard)
Esempio n. 5
0
 def setUp(self):
     wizard = Wizard("Norman", "Stargazer", 1000)
     item = Item("Hat", "Pink", "Glittery", wizard)
     self.loss = Loss("02", "02", "2000",
                      "Lost at event at Gimli's Nightclub", wizard, item)
Esempio n. 6
0
from models.wizard import Wizard
from models.location import Location
from models.spell import Spell
from models.cast import Cast

import repositories.wizard_repository as wizard_repository
import repositories.location_repository as location_repository
import repositories.spell_repository as spell_repository
import repositories.cast_repository as cast_repository

cast_repository.delete_all()
spell_repository.delete_all() 
wizard_repository.delete_all() 
location_repository.delete_all() 

wizard1 = Wizard("Gandalferoo", "DePurple", 2000)
wizard_repository.save(wizard1)
wizard2 = Wizard("Merlin", "McSpells", 1500)
wizard_repository.save(wizard2)
wizard3 = Wizard("Captain", "Magicpants", 200)
wizard_repository.save(wizard3)

location1 = Location("Asda", "Supermarket", "Mordor")
location_repository.save(location1)
location2 = Location("Arthur's Seat", "Natural Wonder", "Edinburgh")
location_repository.save(location2)

spell1 = Spell("Ripe Old Mage", "Age Acceleration", wizard1)
spell_repository.save(spell1)
spell2 = Spell("Spell The Beans", "Relentless Honesty", wizard2)
spell_repository.save(spell2)
Esempio n. 7
0
 def setUp(self):
     self.wizard = Wizard("Norman", "Stargazer", 1000)
     self.spell = Spell("I Wander", "Sudden, Unquenchable Wanderlust",
                        self.wizard)
Esempio n. 8
0
 def setUp(self):
     self.wizard = Wizard("Norman", "Stargazer", 1000)
Esempio n. 9
0
import pdb
from models.wizard import Wizard
from models.item import Item
from models.loss import Loss
import repositories.wizard_repository as wiz_repo
import repositories.item_repository as item_repo
import repositories.loss_repository as loss_repo

loss_repo.delete_all()
item_repo.delete_all()
wiz_repo.delete_all()

wizard1 = Wizard("Gandalferoo", "Frillywhiskers", 2000)
wiz_repo.save(wizard1)
wizard2 = Wizard("Merlin", "Magicpants", 1000)
wiz_repo.save(wizard2)
wizard3 = Wizard("Parry", "Hotter", 22)
wiz_repo.save(wizard3)

hat1 = Item("Hat", "Grey", "Standard; rounded point", wizard1)
item_repo.save(hat1)
hat2 = Item("Hat", "Blue and Yellow", "Standard; sharp point", wizard2)
item_repo.save(hat2)
hat3 = Item("Hat", "Black", "Baseball cap with a lightning bolt", wizard3)
item_repo.save(hat3)
shoes1 = Item("Shoes", "Red and Black", "Jordan Air's", wizard1)
item_repo.save(shoes1)
shoes2 = Item("Shoes", "Blue", "Curly Pointed Slippers", wizard2)
item_repo.save(shoes1)
shoes3 = Item("Shoes", "Black", "90s Platform Trainers", wizard3)
item_repo.save(shoes1)