Allow voucher code to be passed in via query param

Voucher form now accepts a "voucher" query string parameter
with the value to be pre-populated when the form is rendered.
This commit is contained in:
Joel Addison 2020-01-05 17:54:32 +10:00
parent 5b93b39f67
commit ad005a2fb2

View file

@ -650,7 +650,12 @@ def _handle_voucher(request, prefix):
''' Handles a voucher form in the given request. Returns the voucher
form instance, and whether the voucher code was handled. '''
voucher_form = forms.VoucherForm(request.POST or None, prefix=prefix)
initial = {}
if request.GET:
initial = request.GET.copy()
voucher_form = forms.VoucherForm(request.POST or None, prefix=prefix,
initial=initial)
current_cart = CartController.for_user(request.user)
if (voucher_form.is_valid() and