mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
Further cleanup
This commit is contained in:
parent
9733fde689
commit
5f0b342986
2 changed files with 15 additions and 14 deletions
|
@ -2839,10 +2839,11 @@ class PortfolioAdmin(ListHeaderAdmin):
|
||||||
change_form_template = "django/admin/portfolio_change_form.html"
|
change_form_template = "django/admin/portfolio_change_form.html"
|
||||||
fieldsets = [
|
fieldsets = [
|
||||||
(None, {"fields": ["portfolio_type", "organization_name", "creator", "created_at", "notes"]}),
|
(None, {"fields": ["portfolio_type", "organization_name", "creator", "created_at", "notes"]}),
|
||||||
("Portfolio members", {
|
# TODO - uncomment in #2521
|
||||||
"classes": ("collapse", "closed"),
|
# ("Portfolio members", {
|
||||||
"fields": ["administrators", "members"]}
|
# "classes": ("collapse", "closed"),
|
||||||
),
|
# "fields": ["administrators", "members"]}
|
||||||
|
# ),
|
||||||
("Portfolio domains", {
|
("Portfolio domains", {
|
||||||
"classes": ("collapse", "closed"),
|
"classes": ("collapse", "closed"),
|
||||||
"fields": ["domains", "domain_requests"]}
|
"fields": ["domains", "domain_requests"]}
|
||||||
|
@ -2882,16 +2883,8 @@ class PortfolioAdmin(ListHeaderAdmin):
|
||||||
"portfolio_type",
|
"portfolio_type",
|
||||||
]
|
]
|
||||||
|
|
||||||
# TODO - this returns None when empty rather than - for some reason
|
|
||||||
def portfolio_type(self, obj: models.Portfolio):
|
def portfolio_type(self, obj: models.Portfolio):
|
||||||
"""Returns a concat of organization type and federal agency,
|
return obj.portfolio_type if obj.portfolio_type else "-"
|
||||||
seperated by a dash (-)"""
|
|
||||||
org_choices = DomainRequest.OrganizationChoices
|
|
||||||
org_type = org_choices.get_org_label(obj.organization_type)
|
|
||||||
if obj.organization_type == org_choices.FEDERAL and obj.federal_agency:
|
|
||||||
return " - ".join([org_type, obj.federal_agency.agency])
|
|
||||||
else:
|
|
||||||
return org_type
|
|
||||||
|
|
||||||
portfolio_type.short_description = "Portfolio type"
|
portfolio_type.short_description = "Portfolio type"
|
||||||
|
|
||||||
|
@ -2953,7 +2946,7 @@ class PortfolioAdmin(ListHeaderAdmin):
|
||||||
if item_display_value:
|
if item_display_value:
|
||||||
change_url = reverse(f"admin:registrar_{model_name}_change", args=[item.pk])
|
change_url = reverse(f"admin:registrar_{model_name}_change", args=[item.pk])
|
||||||
links.append(f'<a href="{change_url}">{escape(item_display_value)}</a>')
|
links.append(f'<a href="{change_url}">{escape(item_display_value)}</a>')
|
||||||
return format_html(seperator.join(links))
|
return format_html(seperator.join(links)) if links else "-"
|
||||||
|
|
||||||
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"""
|
||||||
|
|
|
@ -121,6 +121,14 @@ class Portfolio(TimeStampedModel):
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return str(self.organization_name)
|
return str(self.organization_name)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def portfolio_type(self):
|
||||||
|
org_type = self.OrganizationChoices.get_org_label(self.organization_type)
|
||||||
|
if self.organization_type == self.OrganizationChoices.FEDERAL and self.federal_agency:
|
||||||
|
return " - ".join([org_type, self.federal_agency.agency])
|
||||||
|
else:
|
||||||
|
return org_type
|
||||||
|
|
||||||
# == Getters for domains == #
|
# == Getters for domains == #
|
||||||
def get_domains(self):
|
def get_domains(self):
|
||||||
"""Returns all DomainInformations associated with this portfolio"""
|
"""Returns all DomainInformations associated with this portfolio"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue