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):
|
||||
value = ", ".join(str(i) for i in value.all())
|
||||
elif isinstance(field, CharField):
|
||||
value = bleach.clean(value)
|
||||
try:
|
||||
value = bleach.clean(value)
|
||||
except TypeError:
|
||||
value = "Bad value for %s" % field.name
|
||||
|
||||
profile_data.append((field.verbose_name, value))
|
||||
|
||||
|
@ -813,7 +816,7 @@ def attendee_data(request, form, user_id=None):
|
|||
return None
|
||||
else:
|
||||
def display_field(value):
|
||||
return bleach.clean(value)
|
||||
return bleach.clean(str(value))
|
||||
|
||||
status_count = lambda status: Case(When( # noqa
|
||||
attendee__user__cart__status=status,
|
||||
|
@ -860,7 +863,10 @@ def attendee_data(request, form, user_id=None):
|
|||
if isinstance(field_type, models.ManyToManyField):
|
||||
return [str(i) for i in attr.all()] or ""
|
||||
else:
|
||||
return bleach.clean(attr)
|
||||
try:
|
||||
return bleach.clean(attr)
|
||||
except TypeError:
|
||||
return "Bad value found for %s" % attr
|
||||
|
||||
headings = ["User ID", "Name", "Email", "Product", "Item Status"]
|
||||
headings.extend(field_names)
|
||||
|
|
Loading…
Reference in a new issue