mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-29 05:56:30 +02:00
User changes
This commit is contained in:
parent
fbd82d5e6f
commit
4c756bba69
2 changed files with 6 additions and 4 deletions
|
@ -865,7 +865,7 @@ class MyUserAdmin(BaseUserAdmin, ImportExportModelAdmin):
|
||||||
"""Returns a list of links for each related suborg"""
|
"""Returns a list of links for each related suborg"""
|
||||||
portfolio_ids = obj.get_portfolios().values_list("portfolio", flat=True)
|
portfolio_ids = obj.get_portfolios().values_list("portfolio", flat=True)
|
||||||
queryset = models.Portfolio.objects.filter(id__in=portfolio_ids)
|
queryset = models.Portfolio.objects.filter(id__in=portfolio_ids)
|
||||||
return get_field_links_as_list(queryset, "portfolio")
|
return get_field_links_as_list(queryset, "portfolio", msg_for_none="No portfolios.")
|
||||||
|
|
||||||
portfolios.short_description = "Portfolios" # type: ignore
|
portfolios.short_description = "Portfolios" # type: ignore
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ def get_action_needed_reason_default_email(request, domain_request, action_neede
|
||||||
|
|
||||||
|
|
||||||
def get_field_links_as_list(
|
def get_field_links_as_list(
|
||||||
queryset, model_name, attribute_name=None, link_info_attribute=None, separator=None
|
queryset, model_name, attribute_name=None, link_info_attribute=None, separator=None, msg_for_none="-",
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Generate HTML links for items in a queryset, using a specified attribute for link text.
|
Generate HTML links for items in a queryset, using a specified attribute for link text.
|
||||||
|
@ -53,6 +53,8 @@ def get_field_links_as_list(
|
||||||
link_info_attribute: Appends f"({value_of_attribute})" to the end of the link.
|
link_info_attribute: Appends f"({value_of_attribute})" to the end of the link.
|
||||||
separator: The separator to use between links in the resulting HTML.
|
separator: The separator to use between links in the resulting HTML.
|
||||||
If none, an unordered list is returned.
|
If none, an unordered list is returned.
|
||||||
|
msg_for_none: What to return when the field would otherwise display None.
|
||||||
|
Defaults to `-`.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A formatted HTML string with links to the admin change pages for each item.
|
A formatted HTML string with links to the admin change pages for each item.
|
||||||
|
@ -80,8 +82,8 @@ def get_field_links_as_list(
|
||||||
|
|
||||||
# If no separator is specified, just return an unordered list.
|
# If no separator is specified, just return an unordered list.
|
||||||
if separator:
|
if separator:
|
||||||
return format_html(separator.join(links)) if links else "-"
|
return format_html(separator.join(links)) if links else msg_for_none
|
||||||
else:
|
else:
|
||||||
links = "".join(links)
|
links = "".join(links)
|
||||||
return format_html(f'<ul class="add-list-reset">{links}</ul>') if links else "-"
|
return format_html(f'<ul class="add-list-reset">{links}</ul>') if links else msg_for_none
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue