コード例 #1
0
def get_order_form(ready_by, order_method):
    site = Site.objects.all()[0]
    location = site.location_set.all()[0]
    request = Mock()
    request.site = site
    request.location = location
    form = OrderForm({
        'name': 'John Smith',
        'phone': '12345',
        'ready_by_0': ready_by.strftime('%I'),
        'ready_by_1': ready_by.strftime('%M'),
        'ready_by_2': ready_by.strftime('%p'),
        'method': order_method,
    }, request=request)
    form.total = '40.00'
    return form
コード例 #2
0
def get_order_form(ready_by, order_method):
    site = Site.objects.all()[0]
    location = site.location_set.all()[0]
    request = Mock()
    request.site = site
    request.location = location
    form = OrderForm(
        {
            'name': 'John Smith',
            'phone': '12345',
            'ready_by_0': ready_by.strftime('%I'),
            'ready_by_1': ready_by.strftime('%M'),
            'ready_by_2': ready_by.strftime('%p'),
            'method': order_method,
        },
        request=request)
    form.total = '40.00'
    return form
コード例 #3
0
ファイル: views.py プロジェクト: tonomuniz/tiger
     messages.warning(request, e.msg)
     return HttpResponseRedirect(e.redirect_to)
 # cart sanity checks:
 # if cart is empty, redirect with message
 if not len(request.cart):
     messages.warning(request, "Your order is empty.  Please add your desired menu items and try again.")
     return HttpResponseRedirect(reverse('menu_home'))
 # if they have an incomplete order, fetch it
 cart_key = request.cart.session.session_key
 try:
     instance = Order.objects.get(session_key=cart_key, status=Order.STATUS_INCOMPLETE)
 except:
     instance = None
 if request.method == 'POST':
     form = OrderForm(request.POST, request=request, instance=instance)
     form.total = request.cart.total()
     if form.is_valid():
         try:
             order = form.save()
         except InvalidOperation:
             form._errors['__all__'] = ErrorList(['Your order is too large.  Please contact us for catering options.'])
         else:
             if request.cart.has_coupon:
                 coupon = Coupon.objects.get(id=request.cart['coupon']['id'])
                 coupon.log_use(order, request.cart.discount())
             if 'pay' in request.POST:
                 request.session['order_id'] = order.id
                 return HttpResponseRedirect(
                     request.site.ordersettings.payment_url(
                         cart_id=request.cart.session.session_key,
                         order_id=order.id