Example #1
0
def save_order(request, id):
    # get mbean info
    mbean = orm.get_mbean_from_id(id)

    # get mbean limit
    total = orm.get_mbean_order_limit(id)

    # get mbean limit
    customer = orm.get_ordercounts_from_mbean(id)

    f = OrderForm()
    if request.POST:

        f = OrderForm(request.POST)
        if f.is_valid():
            o_b_set = f.cleaned_data['o_b_set']

            if customer + o_b_set > total:
                order_error = "*超過可訂購數量"
                return render(request, "suborder.html", RequestContext(request, locals()))
            else:
                o_b_remark = f.cleaned_data['o_b_remark']
                o_p_phone = f.cleaned_data['o_p_phone']
                o_p_address = f.cleaned_data['o_p_address']
                o_m_b = mbean
                o_p_name = request.user

                orm.save_order(o_m_b=o_m_b,
                               o_b_set=o_b_set,
                               o_b_remark=o_b_remark,
                               o_p_name=o_p_name,
                               o_p_phone=o_p_phone,
                               o_p_address=o_p_address)

                # get mbean limit
                customer = orm.get_ordercounts_from_mbean(id)
                f = OrderForm()

        else:
            f = OrderForm()

    return render_to_response('suborder.html', RequestContext(request, locals()))
Example #2
0
def show_detailbean(request, id):
    # get mbean info
    mbean = orm.get_mbean_from_id(id)

    # get mbean limit
    total = orm.get_mbean_order_limit(id)

    # get mbean limit
    customer = orm.get_ordercounts_from_mbean(id)

    orders = orm.get_order_from_mbean(id)

    # f = OrderForm()
    # if request.POST:
    #
    #     f = OrderForm(request.POST)
    #     if f.is_valid():
    #         o_b_set = f.cleaned_data['o_b_set']
    #
    #         if customer + o_b_set > total:
    #             order_error = "*超過可訂購數量"
    #             return render(request, "suborder.html", RequestContext(request, locals()))
    #         else:
    #             o_b_remark = f.cleaned_data['o_b_remark']
    #             o_p_phone = f.cleaned_data['o_p_phone']
    #             o_p_address = f.cleaned_data['o_p_address']
    #             o_m_b = mbean
    #             o_p_name = request.user
    #
    #             orm.save_order(o_m_b=o_m_b,
    #                            o_b_set=o_b_set,
    #                            o_b_remark=o_b_remark,
    #                            o_p_name=o_p_name,
    #                            o_p_phone=o_p_phone,
    #                            o_p_address=o_p_address)
    #
    #             # get mbean limit
    #             customer = orm.get_order_from_mbean(id)
    #
    #     else:
    #         f = OrderForm()

    return render_to_response('users/beandetail.html', RequestContext(request, locals()))