Catch TypeErrors from bleach
This commit is contained in:
parent
e51ad76384
commit
287d412ccf
1 changed files with 9 additions and 3 deletions
|
@ -572,7 +572,10 @@ def attendee(request, form, user_id=None):
|
||||||
if isinstance(field, models.ManyToManyField):
|
if isinstance(field, models.ManyToManyField):
|
||||||
value = ", ".join(str(i) for i in value.all())
|
value = ", ".join(str(i) for i in value.all())
|
||||||
elif isinstance(field, CharField):
|
elif isinstance(field, CharField):
|
||||||
|
try:
|
||||||
value = bleach.clean(value)
|
value = bleach.clean(value)
|
||||||
|
except TypeError:
|
||||||
|
value = "Bad value for %s" % field.name
|
||||||
|
|
||||||
profile_data.append((field.verbose_name, value))
|
profile_data.append((field.verbose_name, value))
|
||||||
|
|
||||||
|
@ -813,7 +816,7 @@ def attendee_data(request, form, user_id=None):
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
def display_field(value):
|
def display_field(value):
|
||||||
return bleach.clean(value)
|
return bleach.clean(str(value))
|
||||||
|
|
||||||
status_count = lambda status: Case(When( # noqa
|
status_count = lambda status: Case(When( # noqa
|
||||||
attendee__user__cart__status=status,
|
attendee__user__cart__status=status,
|
||||||
|
@ -860,7 +863,10 @@ def attendee_data(request, form, user_id=None):
|
||||||
if isinstance(field_type, models.ManyToManyField):
|
if isinstance(field_type, models.ManyToManyField):
|
||||||
return [str(i) for i in attr.all()] or ""
|
return [str(i) for i in attr.all()] or ""
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
return bleach.clean(attr)
|
return bleach.clean(attr)
|
||||||
|
except TypeError:
|
||||||
|
return "Bad value found for %s" % attr
|
||||||
|
|
||||||
headings = ["User ID", "Name", "Email", "Product", "Item Status"]
|
headings = ["User ID", "Name", "Email", "Product", "Item Status"]
|
||||||
headings.extend(field_names)
|
headings.extend(field_names)
|
||||||
|
|
Loading…
Reference in a new issue