def view_wizard_items(id): wizard = wiz_repo.select(id) items = wiz_repo.select_all() return render_template('items/items.html', title='Home', wizard=wizard, items=items)
def select(id): spell = None sql = "SELECT * FROM spells WHERE id = %s" values = [id] result = run_sql(sql, values)[0] if result is not None: wizard = wizard_repository.select(result['wizard_id']) spell = Spell(result['name'], result['description'], wizard, result['id']) return spell
def select_all(): spells = [] sql = "SELECT * FROM spells" results = run_sql(sql) for row in results: wizard = wizard_repository.select(row['wizard_id']) spell = Spell(row['name'], row['description'], wizard, row['id']) spells.append(spell) return spells
def select(id): item = None sql = "SELECT * FROM items WHERE id = %s" values = [id] result = run_sql(sql, values)[0] if result is not None: wizard = wiz_repo.select(result['wizard_id']) item = Item(result['type'], result['colour'], result['style'], wizard, result['id']) return item
def select_all(): items = [] sql = "SELECT * FROM items" results = run_sql(sql) for row in results: wizard = wiz_repo.select(row['wizard_id']) item = Item(row['type'], row['colour'], row['style'], wizard, row['id']) items.append(item) return items
def add_item(): item_type = request.form['type'] item_colour = request.form['colour'] item_style = request.form['style'] wizard_id = request.form['wizard_id'] item_wizard = wiz_repo.select(wizard_id) newItem = Item(type=item_type, colour=item_colour, style=item_style, wizard=item_wizard) item_repo.save(newItem) items = item_repo.select_all() return render_template('items/items.html', title='Home', items=items)
def active_losses(): losses = [] sql = "SELECT * FROM losses where recovered = False" results = run_sql(sql) for row in results: wizard = wiz_repo.select(row['wizard_id']) item = item_repo.select(row['item_id']) loss = Loss(row['day'], row['month'], row['year'], row['details'], wizard, item, row['recovered'], row['id']) losses.append(loss) return losses
def select(id): loss = None sql = "SELECT * FROM losses WHERE id = %s" values = [id] result = run_sql(sql, values)[0] if result is not None: wizard = wiz_repo.select(result['wizard_id']) item = item_repo.select(result['spell_id']) loss = Loss(result['day'], result['month'], result['year'], result['details'], wizard, item, result['recovered'], result['id']) return loss
def select(id): cast = None sql = "SELECT * FROM casts WHERE id = %s" values = [id] result = run_sql(sql, values)[0] if result is not None: wizard = wizard_repository.select(result['wizard_id']) spell = spell_repository.select(result['spell_id']) location = location_repository.select(result['location_id']) cast = Cast(result['deaths'], result['details'], wizard, spell, location, result['id']) return cast
def loss_history(wizard): losses = [] sql = "SELECT * FROM losses where wizard_id = %s AND recovered = False" values = [wizard.id] results = run_sql(sql, values) for row in results: wizard = wiz_repo.select(row['wizard_id']) item = item_repo.select(row['item_id']) loss = Loss(row['day'], row['month'], row['year'], row['details'], wizard, item, row['recovered'], row['id']) losses.append(loss) return losses
def select_all(): casts = [] sql = "SELECT * FROM casts" results = run_sql(sql) for row in results: wizard = wizard_repository.select(row['wizard_id']) spell = spell_repository.select(row['spell_id']) location = location_repository.select(row['location_id']) cast = Cast(row['deaths'], row['details'], wizard, spell, location, row['id']) casts.append(cast) return casts
def new_item(id): wizard = wiz_repo.select(id) # wizard_id = wizard.id return render_template('wizards/new_item.html', wizard=wizard)
def edit_wizard(id): wizard = wiz_repo.select(id) return render_template('wizards/edit.html', wizard=wizard)
def show_wizard(id): wizard = wiz_repo.select(id) return render_template('wizards/show.html', wizard=wizard)