You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

views.py 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from django.shortcuts import render
  2. from oscar.checkout.views import (ShippingMethodView as CoreShippingMethodView,
  3. PaymentView as CorePaymentView, prev_steps_must_be_complete)
  4. from oscar.payment.forms import BankcardForm
  5. from oscar.services import import_module
  6. shipping_models = import_module('shipping.models', ['Method'])
  7. class ShippingMethodView(CoreShippingMethodView):
  8. def get_shipping_methods_for_basket(self, basket):
  9. codes = ['royal-mail-first-class']
  10. # Only allow parcel force if dropship products are include
  11. for line in basket.lines.all():
  12. if line.product.stockrecord.partner_id == 2:
  13. codes.append('parcel-force')
  14. return shipping_models.Method.objects.filter(code__in=codes)
  15. class PaymentView(CorePaymentView):
  16. @prev_steps_must_be_complete
  17. def __call__(self, request):
  18. assert False
  19. # Display credit card form
  20. form = BankcardForm()
  21. return render(request, 'checkout/payment.html', locals())
  22. def success(self):
  23. mark_step_as_complete(request)
  24. return HttpResponseRedirect(reverse(get_next_step(request)))