Fix some user feedback form handling

sheesh i don't see how this hasn't been more broken for some time now...
This commit is contained in:
Lance Edgar 2019-08-04 22:36:58 -05:00
parent fda7230bce
commit 243c69b231
2 changed files with 31 additions and 3 deletions

View file

@ -923,6 +923,16 @@ class Form(object):
# https://docs.pylonsproject.org/projects/pyramid/en/latest/api/request.html#pyramid.request.Request.is_xhr
if self.request.is_xhr:
controls = self.request.json_body.items()
# TODO: why in the hell is this necessary? some colander forms
# won't validate if a `None` sneaks its way through? note, in
# particular this was needed to allow anonymous user feedback
controls = [[key, val] for key, val in controls]
for i in range(len(controls)):
key, value = controls[i]
if value is None:
controls[i][1] = ''
else:
controls = self.request.POST.items()