def test_itemSearch(): nameAssert = 'name didn\'t match or was absent.' assert sqlItemSearch('name', 'nier automata').name == 'nier automata', name ownerAssert = 'owner didn\'t match or was absent.' assert sqlItemSearch('owner', 'Vorian')[0].owner == 'Vorian', owner cataAssert = 'catagory didn\'t match or was absent.' assert sqlItemSearch('catagory', 'rpg')[0].catagory == 'rpg', cata
def deleteItem(item_name): item = sqlItemSearch('name', item_name) if checkLogin(True, item): if request.method == 'GET': return render_template('deleteitem.html', item=item) if request.method == 'POST': crud_delete(item) return redirect(url_for('viewAll_catagory', catagory=item.catagory)) else: return redirect(url_for('viewAll_catagory', catagory=item.catagory))
def editItem(item_name): item = sqlItemSearch('name', item_name) if checkLogin(True, item): catagories = session.query(Catagory).all() if request.method == 'GET': return render_template('edititem.html', item=item, catagories=catagories) if request.method == 'POST': crud_edit(item) return redirect(url_for('viewAll_owner', owner=item.owner)) else: return redirect(url_for('viewAll_owner', owner=item.owner))
def viewItem(item_name): item = sqlItemSearch('name', item_name) if request.method == 'GET': return render_template('viewitem.html', item=item)
def viewAll_catagory(catagory): items = sqlItemSearch('catagory', catagory) if request.method == 'GET': return render_template('viewcatagory.html', catagory=catagory, items=items)
def viewAll_owner(owner): items = sqlItemSearch('owner', owner.capitalize()) if request.method == 'GET' and checkLogin(): return render_template('viewowner.html', owner=owner, items=items) else: return redirect(url_for('homepage'))
def api_showItem(item_name): item = sqlItemSearch('name', item_name) return jsonify(item.serialize)
def api_showCatagory(catagory_name): items = sqlItemSearch('catagory', catagory_name) return jsonify(catagoryItems=[i.serialize for i in items])
def api_showOwner(owner_name): items = sqlItemSearch('owner', owner_name) return jsonify(ownerItems=[i.serialize for i in items])