Пример #1
0
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
Пример #2
0
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))
Пример #3
0
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))
Пример #4
0
def viewItem(item_name):
    item = sqlItemSearch('name', item_name)
    if request.method == 'GET':
        return render_template('viewitem.html', item=item)
Пример #5
0
def viewAll_catagory(catagory):
    items = sqlItemSearch('catagory', catagory)
    if request.method == 'GET':
        return render_template('viewcatagory.html',
                               catagory=catagory, items=items)
Пример #6
0
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'))
Пример #7
0
def api_showItem(item_name):
    item = sqlItemSearch('name', item_name)
    return jsonify(item.serialize)
Пример #8
0
def api_showCatagory(catagory_name):
    items = sqlItemSearch('catagory', catagory_name)
    return jsonify(catagoryItems=[i.serialize for i in items])
Пример #9
0
def api_showOwner(owner_name):
    items = sqlItemSearch('owner', owner_name)
    return jsonify(ownerItems=[i.serialize for i in items])