mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 17:17:02 +02:00
Revise to show ellipsis with numbers, unit tests
This commit is contained in:
parent
a9a256127a
commit
6c8e1fec59
3 changed files with 85 additions and 13 deletions
|
@ -491,11 +491,14 @@ class ContactAdmin(ListHeaderAdmin):
|
|||
|
||||
if related_objects:
|
||||
message = ""
|
||||
for url, obj in related_objects:
|
||||
escaped_obj = escape(obj)
|
||||
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
|
||||
# which are generated from django objects. And a django object, which is escaped
|
||||
for i, (url, obj) in enumerate(related_objects):
|
||||
if i < 5:
|
||||
escaped_obj = escape(obj)
|
||||
message += f"Joined to {obj.__class__.__name__}: <a href='{url}'>{escaped_obj}</a><br/>"
|
||||
if len(related_objects) > 5:
|
||||
related_objects_over_five = len(related_objects) - 5
|
||||
message += f"And {related_objects_over_five} more..."
|
||||
|
||||
message_html = mark_safe(message) # nosec
|
||||
messages.warning(
|
||||
request,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue