I attempted to apply a voucher code to a user using the staff "amend invoice" view, but got the following traceback:
ERROR 2017-07-17 19:59:08,208 base 19647 139739945805568 Internal Server Error: /tickets/amend/428
Traceback (most recent call last):
File "/srv/http/2017.pycon-au.org/symposion/lib/python2.7/site-packages/django/core/handlers/base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "/srv/http/2017.pycon-au.org/symposion/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/srv/http/2017.pycon-au.org/symposion/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/srv/http/2017.pycon-au.org/symposion/src/registrasion/registrasion/views.py", line 968, in amend_registration
for item, form in zip(items, formset):
File "/srv/http/2017.pycon-au.org/symposion/lib/python2.7/site-packages/django/forms/formsets.py", line 81, in __len__
return len(self.forms)
File "/srv/http/2017.pycon-au.org/symposion/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/srv/http/2017.pycon-au.org/symposion/lib/python2.7/site-packages/django/forms/formsets.py", line 144, in forms
for i in range(self.total_form_count())]
File "/srv/http/2017.pycon-au.org/symposion/lib/python2.7/site-packages/django/forms/formsets.py", line 116, in total_form_count
return min(self.management_form.cleaned_data[TOTAL_FORM_COUNT], self.absolute_max)
File "/srv/http/2017.pycon-au.org/symposion/lib/python2.7/site-packages/django/forms/formsets.py", line 98, in management_form
code='missing_management_form',
ValidationError: [u'ManagementForm data is missing or has been tampered with']
The problem appears to be that the "apply voucher" form does not include any of the metadata about the products form. The formset constructed here is thus invalid:
https://github.com/chrisjrn/registrasion/blob/master/registrasion/views.py#L961
It cannot be iterated over, producing the above traceback.
I managed to work around this on the pyconau2017 site editing the HTML, putting invalid "product" form data in the "voucher" form so that it will pass the above checks and proceed to apply the voucher.
It may be that adding an if formset.is_valid(): guard around this block of code:
https://github.com/chrisjrn/registrasion/blob/master/registrasion/views.py#L967
Will be enough to fix the issue. I'm sorry I don't have the bandwidth to set up a dev environment and dig in and submit a fix as a PR :-(
I attempted to apply a voucher code to a user using the staff "amend invoice" view, but got the following traceback:
The problem appears to be that the "apply voucher" form does not include any of the metadata about the products form. The formset constructed here is thus invalid:
https://github.com/chrisjrn/registrasion/blob/master/registrasion/views.py#L961
It cannot be iterated over, producing the above traceback.
I managed to work around this on the pyconau2017 site editing the HTML, putting invalid "product" form data in the "voucher" form so that it will pass the above checks and proceed to apply the voucher.
It may be that adding an
if formset.is_valid():guard around this block of code:https://github.com/chrisjrn/registrasion/blob/master/registrasion/views.py#L967
Will be enough to fix the issue. I'm sorry I don't have the bandwidth to set up a dev environment and dig in and submit a fix as a PR :-(