put all messages in one warning, rather than multiple

This commit is contained in:
David Kennedy 2024-01-23 13:47:47 -05:00
parent bcbd7927b3
commit a9a256127a
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B

View file

@ -490,16 +490,17 @@ class ContactAdmin(ListHeaderAdmin):
related_objects.append((change_url, obj)) related_objects.append((change_url, obj))
if related_objects: if related_objects:
message = ""
for url, obj in related_objects: for url, obj in related_objects:
escaped_obj = escape(obj) escaped_obj = escape(obj)
message = f"Joined to {obj.__class__.__name__}: <a href='{url}'>{escaped_obj}</a>" message += f"Joined to {obj.__class__.__name__}: <a href='{url}'>{escaped_obj}</a><br/>"
# message_html is considered safe html. It is generated from a finite list of strings # message_html is considered safe html. It is generated from a finite list of strings
# which are generated from django objects. And a django object, which is escaped # which are generated from django objects. And a django object, which is escaped
message_html = mark_safe(message) # nosec message_html = mark_safe(message) # nosec
messages.warning( messages.warning(
request, request,
message_html, message_html,
) )
return super().change_view(request, object_id, form_url, extra_context=extra_context) return super().change_view(request, object_id, form_url, extra_context=extra_context)