예제 #1
0
파일: cart.py 프로젝트: sheimi/online-shop
def confirm_all(order_id):
    order = get_object_or_404(UserOrder, id=order_id)
    status = get_object_or_404(OrderStatus, name="confirmed")
    UserOrder.update(is_confirmed=True, status=status, confirm_date=dt.today()).where(id=order_id).execute()
    point = g.user.point
    point += order.total_price()
    User.update(point=point).where(id=g.user.id).execute()
    return render_template("cart/success.html", user=g.user, order=order)
예제 #2
0
def image_delete():
    img = get_object_or_404(CommodityImage, id=request.json.get('id', None))
    img.delete_instance()
    path = "/".join(['./static/img/commodity', img.name])
    import os
    os.remove(path)
    return jsonify(success=True)
예제 #3
0
def image_upload(com_id):
    datafile = request.files['file']
    filename = datafile.filename
    path = "/".join(['./static/img/commodity', filename])
    url = "/".join(['/static/img/commodity', filename])

    commodity = get_object_or_404(Commodity, id=com_id)
    img = CommodityImage.create(name=filename, commodity=commodity)

    datafile.save(path)
    return jsonify(success=True, url=url, img_id=img.id)
예제 #4
0
def feed(feed_id):
    feed_item = get_object_or_404(Feedback, id=feed_id)
    return render_template("feedback/feed_item.html", feed=feed_item)
예제 #5
0
파일: cart.py 프로젝트: sheimi/online-shop
def confirm_order(order_id):
    order = get_object_or_404(UserOrder, id=order_id)
    if order.is_confirmed:
        # TODO
        return render_template("cart/success.html", user=g.user, order=order)
    return render_template("cart/confirm.html", user=g.user, order=order)
예제 #6
0
파일: cart.py 프로젝트: sheimi/online-shop
def check_payment(order_id):
    order = get_object_or_404(UserOrder, id=order_id)
    if order.is_confirmed:
        # TODO
        return render_template("cart/success.html", user=g.user, order=order)
    return redirect(url_for(".confirm_order", order_id=order_id))
예제 #7
0
파일: cart.py 프로젝트: sheimi/online-shop
def additem():
    json = request.json
    order = get_object_or_404(UserOrder, id=json["order"])
    commodity = Commodity.select().get(id=json["commodity"])
    OrderItem.create(commodity=commodity, order=order, num=json["num"], price=commodity.price)
    return jsonify(success=True)
예제 #8
0
파일: core.py 프로젝트: sheimi/online-shop
def compare_box():
    c1 = get_object_or_404(Commodity, id=request.args.get("c1"))
    c2 = get_object_or_404(Commodity, id=request.args.get("c2"))
    return render_template('core/compare_box.html', c1=c1, c2=c2)
예제 #9
0
def commodity_image(com_id):
    commodity = get_object_or_404(Commodity, id=com_id)
    return render_template('admin/admina/image_list.html', commodity=commodity)
예제 #10
0
def categories():
    root = get_object_or_404(Category, id=1)
    return render_template('admin/admina/categories.html', root=root)