This commit is contained in:
zandercymatics 2024-08-13 14:35:59 -06:00
parent ba1392e6cc
commit fa28412e31
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 10 additions and 12 deletions

View file

@ -2867,19 +2867,16 @@ class PortfolioAdmin(ListHeaderAdmin):
("Senior official", {"fields": ["senior_official"]}), ("Senior official", {"fields": ["senior_official"]}),
] ]
# NOTE: use add_fieldsets to modify that page
list_display = ("organization_name", "federal_agency", "creator") list_display = ("organization_name", "federal_agency", "creator")
search_fields = ["organization_name"] search_fields = ["organization_name"]
search_help_text = "Search by organization name." search_help_text = "Search by organization name."
readonly_fields = [ readonly_fields = [
"created_at", "created_at",
"federal_type",
# Custom fields such as these must be defined as readonly. # Custom fields such as these must be defined as readonly.
"administrators",
"members",
"domains", "domains",
"domain_requests", "domain_requests",
"suborganizations", "suborganizations",
"federal_type",
"portfolio_type", "portfolio_type",
] ]
@ -2951,7 +2948,14 @@ class PortfolioAdmin(ListHeaderAdmin):
def change_view(self, request, object_id, form_url="", extra_context=None): def change_view(self, request, object_id, form_url="", extra_context=None):
"""Add related suborganizations and domain groups""" """Add related suborganizations and domain groups"""
obj = self.get_object(request, object_id) obj = self.get_object(request, object_id)
extra_context = {"administrators": obj.get_administrators(), "members": obj.get_members()}
# ---- Domain Groups
domain_groups = DomainGroup.objects.filter(portfolio=obj)
# ---- Suborganizations
suborganizations = Suborganization.objects.filter(portfolio=obj)
extra_context = {"domain_groups": domain_groups, "suborganizations": suborganizations}
return super().change_view(request, object_id, form_url, extra_context) return super().change_view(request, object_id, form_url, extra_context)
def save_model(self, request, obj, form, change): def save_model(self, request, obj, form, change):

View file

@ -4,13 +4,7 @@
{% block field_sets %} {% block field_sets %}
{% for fieldset in adminform %} {% for fieldset in adminform %}
{% comment %} {% comment %}
TODO: this will eventually need to be changed to something like this This is a placeholder for now
if we ever want to customize this file:
{% include "django/admin/includes/domain_information_fieldset.html" %}
Use detail_table_fieldset as an example, or just extend it.
original_object is just a variable name for "DomainInformation" or "DomainRequest"
{% endcomment %} {% endcomment %}
{% include "django/admin/includes/detail_table_fieldset.html" with original_object=original %} {% include "django/admin/includes/detail_table_fieldset.html" with original_object=original %}
{% endfor %} {% endfor %}