daily pastebin goal
9%
SHARE
TWEET

Untitled

a guest Mar 15th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. path('payment/',views.payment,name='payment'),
  2. path('checkout/', views.checkout, name="checkout"),
  3.      
  4. def checkout(request):
  5.         request.session.pop('data', None)
  6.         messages.success(request,'Done.Thanks for using our services.')
  7.         return redirect("shop:mycart")
  8.  
  9.         def payment(request):
  10.             return render(request,'shop/payment.html')
  11.  
  12.         def buy_now(request,slug):
  13.         if not request.user.is_authenticated:
  14.             messages.info(request, 'You have to logged in first.')
  15.             return redirect('%s?next=%s' % (settings.LOGIN_URL, request.path))
  16.         product = Product.objects.get(active=True, slug=slug)
  17.         if request.method == "POST":
  18.             form = BuyerDeliveryForm(request.POST)
  19.             if form.is_valid():
  20.                 buyer = form.save(commit=False)
  21.                 buyer.save()
  22.                 return redirect('shop:payment')
  23.         else:
  24.             form = BuyerDeliveryForm()
  25.         return render(request, 'shop/delivery_form.html', {'form': form, 'products': product})
  26.  
  27.  
  28.     def items_buy_now(request):
  29.         if not request.user.is_authenticated:
  30.             messages.info(request, 'You have to logged in first.')
  31.             return redirect('%s?next=%s' % (settings.LOGIN_URL, request.path))
  32.         if request.method == "POST":
  33.             form = BuyerDeliveryForm(request.POST)
  34.             if form.is_valid():
  35.                 buyer = form.save(commit=False)
  36.                 buyer.save()
  37.                 return redirect('shop:payment')
  38.         else:
  39.             form = BuyerDeliveryForm()
  40.         return render(request, 'shop/delivery_form.html', {'form': form})
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top