예제 #1
0
파일: views.py 프로젝트: jasenc/catalog
def itemXML(category_id, item_id):
    category = models.category_get(category_id)
    item = models.item_get(item_id)
    page = {'CatalogItem': [item.serialize]}
    xml = dicttoxml(page)
    dom = parseString(xml)
    return Response(dom.toprettyxml(), mimetype='text/xml')
예제 #2
0
파일: views.py 프로젝트: jasenc/catalog
def editItem(category_id, item_id):
    if 'email' in login_session.keys():
        edit_item = models.item_get(item_id)
        user_id = models.getUserID(login_session['email'])
        if edit_item.user_id == user_id:
            form = forms.itemForm(request.form)
            user = models.getUserInfo(user_id)
            category = models.category_get(category_id)
            if request.method == 'POST' and form.validate():
                edit_item.name = form.name.data
                edit_item.image = form.image.data
                edit_item.description = form.description.data
                models.item_edit(edit_item)
                items = models.items_get_by_category(category_id)
                return render_template('categories/show.html',
                                       category=category,
                                       items=items, user=user)
            else:
                return render_template('items/edit.html', category=category,
                                       item=edit_item, form=form, user=user)
        else:
            flash("You aren't the owner for that.")
            return redirect(url_for('showCategory', category_id=category_id))
    else:
        return redirect(url_for('showCategory', category_id=category_id))
예제 #3
0
파일: views.py 프로젝트: jasenc/catalog
def showItem(category_id, item_id):
    category = models.category_get(category_id)
    item = models.item_get(item_id)
    if 'email' in login_session.keys():
        user_id = models.getUserID(login_session['email'])
        user = models.getUserInfo(user_id)
        return render_template('items/show.html', category=category,
                               item=item, user=user)
    else:
        return render_template('items/public.html',
                               category=category, item=item)
예제 #4
0
파일: views.py 프로젝트: jasenc/catalog
def deleteItem(category_id, item_id):
    if 'email' in login_session.keys():
        delete_item = models.item_get(item_id)
        user_id = models.getUserID(login_session['email'])
        if delete_item.user_id == user_id:
            form = forms.deleteForm(request.form)
            category = models.category_get(category_id)
            user = models.getUserInfo(user_id)
            if request.method == 'POST':
                models.item_delete(delete_item)
                return redirect(url_for('showCategory',
                                        category_id=category.id))
            else:
                return render_template('items/delete.html', category=category,
                                       item=delete_item, user=user, form=form)
        else:
            flash("You aren't the owner for that.")
            return redirect(url_for('showCategory', category_id=category_id))
    else:
        return redirect(url_for('showCategory', category_id=category_id))
예제 #5
0
파일: views.py 프로젝트: jasenc/catalog
def itemJSON(category_id, item_id):
    category = models.category_get(category_id)
    item = models.item_get(item_id)
    return jsonify(CatalogItem=[item.serialize])