mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
Remove items not part of ACs
Remove the content for members
This commit is contained in:
parent
5f0b342986
commit
ba1392e6cc
4 changed files with 19 additions and 61 deletions
|
@ -2892,7 +2892,7 @@ class PortfolioAdmin(ListHeaderAdmin):
|
||||||
"""Returns a comma seperated list of links for each related suborg"""
|
"""Returns a comma seperated list of links for each related suborg"""
|
||||||
queryset = obj.get_suborganizations()
|
queryset = obj.get_suborganizations()
|
||||||
sep = '<div class="display-block margin-top-1"></div>'
|
sep = '<div class="display-block margin-top-1"></div>'
|
||||||
return self.get_links_csv(queryset, "suborganization", seperator=sep)
|
return self.get_field_links_as_csv(queryset, "suborganization", seperator=sep)
|
||||||
|
|
||||||
suborganizations.short_description = "Suborganizations"
|
suborganizations.short_description = "Suborganizations"
|
||||||
|
|
||||||
|
@ -2900,7 +2900,7 @@ class PortfolioAdmin(ListHeaderAdmin):
|
||||||
"""Returns a comma seperated list of links for each related domain"""
|
"""Returns a comma seperated list of links for each related domain"""
|
||||||
queryset = obj.get_domains()
|
queryset = obj.get_domains()
|
||||||
sep = '<div class="display-block margin-top-1"></div>'
|
sep = '<div class="display-block margin-top-1"></div>'
|
||||||
return self.get_links_csv(queryset, "domaininformation", seperator=sep)
|
return self.get_field_links_as_csv(queryset, "domaininformation", seperator=sep)
|
||||||
|
|
||||||
domains.short_description = "Domains"
|
domains.short_description = "Domains"
|
||||||
|
|
||||||
|
@ -2908,24 +2908,10 @@ class PortfolioAdmin(ListHeaderAdmin):
|
||||||
"""Returns a comma seperated list of links for each related domain request"""
|
"""Returns a comma seperated list of links for each related domain request"""
|
||||||
queryset = obj.get_domain_requests()
|
queryset = obj.get_domain_requests()
|
||||||
sep = '<div class="display-block margin-top-1"></div>'
|
sep = '<div class="display-block margin-top-1"></div>'
|
||||||
return self.get_links_csv(queryset, "domainrequest", seperator=sep)
|
return self.get_field_links_as_csv(queryset, "domainrequest", seperator=sep)
|
||||||
|
|
||||||
domain_requests.short_description = "Domain requests"
|
domain_requests.short_description = "Domain requests"
|
||||||
|
|
||||||
def administrators(self, obj: models.Portfolio):
|
|
||||||
"""Returns a comma seperated list of links for each related administrator"""
|
|
||||||
queryset = obj.get_administrators()
|
|
||||||
return self.get_links_csv(queryset, "user", "get_full_name")
|
|
||||||
|
|
||||||
administrators.short_description = "Administrators"
|
|
||||||
|
|
||||||
def members(self, obj: models.Portfolio):
|
|
||||||
"""Returns a comma seperated list of links for each related member"""
|
|
||||||
queryset = obj.get_members()
|
|
||||||
return self.get_links_csv(queryset, "user", "get_full_name")
|
|
||||||
|
|
||||||
members.short_description = "Members"
|
|
||||||
|
|
||||||
# Creates select2 fields (with search bars)
|
# Creates select2 fields (with search bars)
|
||||||
autocomplete_fields = [
|
autocomplete_fields = [
|
||||||
"creator",
|
"creator",
|
||||||
|
@ -2933,9 +2919,23 @@ class PortfolioAdmin(ListHeaderAdmin):
|
||||||
]
|
]
|
||||||
|
|
||||||
# Q for reviewers: What should this be called?
|
# Q for reviewers: What should this be called?
|
||||||
def get_links_csv(self, queryset, model_name, link_text_attribute=None, seperator=", "):
|
def get_field_links_as_csv(self, queryset, model_name, link_text_attribute=None, seperator=", "):
|
||||||
|
"""
|
||||||
|
Generate HTML links for items in a queryset, using a specified attribute for link text.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
queryset: The queryset of items to generate links for.
|
||||||
|
model_name: The model name used to construct the admin change URL.
|
||||||
|
link_text_attribute: The attribute or method name to use for link text. If None, the item itself is used.
|
||||||
|
separator: The separator to use between links in the resulting HTML.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A formatted HTML string with links to the admin change pages for each item.
|
||||||
|
"""
|
||||||
links = []
|
links = []
|
||||||
for item in queryset:
|
for item in queryset:
|
||||||
|
|
||||||
|
# This allows you to pass in link_text_attribute="get_full_name" for instance.
|
||||||
if link_text_attribute:
|
if link_text_attribute:
|
||||||
item_display_value = getattr(item, link_text_attribute)
|
item_display_value = getattr(item, link_text_attribute)
|
||||||
if callable(item_display_value):
|
if callable(item_display_value):
|
||||||
|
|
|
@ -142,32 +142,3 @@ class Portfolio(TimeStampedModel):
|
||||||
def get_suborganizations(self):
|
def get_suborganizations(self):
|
||||||
"""Returns all suborganizations associated with this portfolio"""
|
"""Returns all suborganizations associated with this portfolio"""
|
||||||
return self.portfolio_suborganizations.all()
|
return self.portfolio_suborganizations.all()
|
||||||
|
|
||||||
# == Getters for users == #
|
|
||||||
def get_users(self):
|
|
||||||
"""Returns all users associated with this portfolio"""
|
|
||||||
return self.portfolio_users.all()
|
|
||||||
|
|
||||||
def get_administrators(self):
|
|
||||||
"""Returns all administrators associated with this portfolio"""
|
|
||||||
return self.portfolio_users.filter(
|
|
||||||
portfolio_roles__overlap=[
|
|
||||||
UserPortfolioRoleChoices.ORGANIZATION_ADMIN,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_readonly_administrators(self):
|
|
||||||
"""Returns all readonly_administrators associated with this portfolio"""
|
|
||||||
return self.portfolio_users.filter(
|
|
||||||
portfolio_roles__overlap=[
|
|
||||||
UserPortfolioRoleChoices.ORGANIZATION_ADMIN_READ_ONLY,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_members(self):
|
|
||||||
"""Returns all members associated with this portfolio"""
|
|
||||||
return self.portfolio_users.filter(
|
|
||||||
portfolio_roles__overlap=[
|
|
||||||
UserPortfolioRoleChoices.ORGANIZATION_MEMBER,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{% extends "django/admin/includes/email_clipboard_fieldset.html" %}
|
|
||||||
{% load custom_filters %}
|
|
||||||
{% load static url_helpers %}
|
|
||||||
|
|
||||||
{% block field_readonly %}
|
|
||||||
{% if field.field.name == "members" %}
|
|
||||||
{% comment %} Do nothing - for now {% endcomment %}
|
|
||||||
<div class="readonly">{{ field.contents }}</div>
|
|
||||||
{% else %}
|
|
||||||
<div class="readonly">{{ field.contents }}</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock field_readonly %}
|
|
||||||
|
|
|
@ -12,6 +12,6 @@
|
||||||
|
|
||||||
original_object is just a variable name for "DomainInformation" or "DomainRequest"
|
original_object is just a variable name for "DomainInformation" or "DomainRequest"
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
{% include "django/admin/includes/portfolio_fieldset.html" with original_object=original %}
|
{% include "django/admin/includes/detail_table_fieldset.html" with original_object=original %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue