mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 00:57:02 +02:00
Make federal_type readonly
This commit is contained in:
parent
9059ce3281
commit
06b66f4400
4 changed files with 47 additions and 46 deletions
|
@ -23,6 +23,7 @@ from registrar.models.user_domain_role import UserDomainRole
|
|||
from waffle.admin import FlagAdmin
|
||||
from waffle.models import Sample, Switch
|
||||
from registrar.models import Contact, Domain, DomainRequest, DraftDomain, User, Website, SeniorOfficial
|
||||
from registrar.utility.constants import BranchChoices
|
||||
from registrar.utility.errors import FSMDomainRequestError, FSMErrorCodes
|
||||
from registrar.views.utility.mixins import OrderableFieldsMixin
|
||||
from django.contrib.admin.views.main import ORDER_VAR
|
||||
|
@ -2896,7 +2897,7 @@ class PortfolioAdmin(ListHeaderAdmin):
|
|||
# This is the fieldset display when adding a new model
|
||||
add_fieldsets = [
|
||||
(None, {"fields": ["organization_name", "creator", "notes"]}),
|
||||
("Type of organization", {"fields": ["organization_type", "federal_type"]}),
|
||||
("Type of organization", {"fields": ["organization_type"]}),
|
||||
(
|
||||
"Organization name and mailing address",
|
||||
{
|
||||
|
@ -2914,12 +2915,6 @@ class PortfolioAdmin(ListHeaderAdmin):
|
|||
("Senior official", {"fields": ["senior_official"]}),
|
||||
]
|
||||
|
||||
# NOT all fields are readonly for admin, otherwise we would have
|
||||
# set this at the permissions level. The exception is 'status'
|
||||
analyst_readonly_fields = [
|
||||
"federal_type",
|
||||
]
|
||||
|
||||
list_display = ("organization_name", "federal_agency", "creator")
|
||||
search_fields = ["organization_name"]
|
||||
search_help_text = "Search by organization name."
|
||||
|
@ -2927,12 +2922,19 @@ class PortfolioAdmin(ListHeaderAdmin):
|
|||
# This is the created_at field
|
||||
"created_on",
|
||||
# Custom fields such as these must be defined as readonly.
|
||||
"federal_type",
|
||||
"domains",
|
||||
"domain_requests",
|
||||
"suborganizations",
|
||||
"portfolio_type",
|
||||
]
|
||||
|
||||
def federal_type(self, obj: models.portfolio):
|
||||
"""Returns the federal_type field"""
|
||||
return BranchChoices.get_branch_label(obj.federal_type) if obj.federal_type else "-"
|
||||
|
||||
federal_type.short_description = "Federal type"
|
||||
|
||||
def created_on(self, obj: models.Portfolio):
|
||||
"""Returns the created_at field, with a different short description"""
|
||||
# Format: Dec 12, 2024
|
||||
|
|
|
@ -881,22 +881,6 @@ function initializeWidgetOnList(list, parentId) {
|
|||
.catch(error => console.error("Error fetching senior official: ", error));
|
||||
}
|
||||
|
||||
function updateContactInfo(data) {
|
||||
if (!contactList) return;
|
||||
|
||||
const titleSpan = contactList.querySelector("#contact_info_title");
|
||||
const emailSpan = contactList.querySelector("#contact_info_email");
|
||||
const phoneSpan = contactList.querySelector("#contact_info_phone");
|
||||
|
||||
if (titleSpan) titleSpan.textContent = data.title || "";
|
||||
if (emailSpan) {
|
||||
emailSpan.textContent = data.email || "";
|
||||
const clipboardInput = contactList.querySelector(".admin-icon-group input");
|
||||
if (clipboardInput) clipboardInput.value = data.email || "";
|
||||
}
|
||||
if (phoneSpan) phoneSpan.textContent = data.phone || "";
|
||||
}
|
||||
|
||||
function handleStateTerritoryChange(stateTerritory, urbanizationField) {
|
||||
let selectedValue = stateTerritory.value;
|
||||
if (selectedValue === "PR") {
|
||||
|
@ -905,4 +889,29 @@ function initializeWidgetOnList(list, parentId) {
|
|||
hideElement(urbanizationField)
|
||||
}
|
||||
}
|
||||
|
||||
function updateContactInfo(data) {
|
||||
if (!contactList) return;
|
||||
|
||||
const titleSpan = contactList.querySelector("#contact_info_title");
|
||||
const emailSpan = contactList.querySelector("#contact_info_email");
|
||||
const phoneSpan = contactList.querySelector("#contact_info_phone");
|
||||
|
||||
if (titleSpan) {
|
||||
titleSpan.textContent = data.title || "";
|
||||
};
|
||||
|
||||
// Update the email field and the content for the clipboard
|
||||
if (emailSpan) {
|
||||
emailSpan.textContent = data.email || "";
|
||||
const clipboardInput = contactList.querySelector(".admin-icon-group input");
|
||||
if (clipboardInput) {
|
||||
clipboardInput.value = data.email || "";
|
||||
};
|
||||
}
|
||||
|
||||
if (phoneSpan) {
|
||||
phoneSpan.textContent = data.phone || "";
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 4.2.10 on 2024-08-14 18:50
|
||||
# Generated by Django 4.2.10 on 2024-08-15 15:32
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
@ -16,16 +16,6 @@ class Migration(migrations.Migration):
|
|||
name="portfolio",
|
||||
options={"ordering": ["organization_name"]},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="portfolio",
|
||||
name="federal_type",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
choices=[("executive", "Executive"), ("judicial", "Judicial"), ("legislative", "Legislative")],
|
||||
max_length=50,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="portfolio",
|
||||
name="creator",
|
|
@ -58,13 +58,6 @@ class Portfolio(TimeStampedModel):
|
|||
default=FederalAgency.get_non_federal_agency,
|
||||
)
|
||||
|
||||
federal_type = models.CharField(
|
||||
max_length=50,
|
||||
choices=BranchChoices.choices,
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
senior_official = models.ForeignKey(
|
||||
"registrar.SeniorOfficial",
|
||||
on_delete=models.PROTECT,
|
||||
|
@ -136,12 +129,19 @@ class Portfolio(TimeStampedModel):
|
|||
def portfolio_type(self):
|
||||
"""
|
||||
Returns a combination of organization_type / federal_type, seperated by ' - '.
|
||||
If no federal_type is found, we just return the org type."""
|
||||
org_type = self.OrganizationChoices.get_org_label(self.organization_type)
|
||||
if self.organization_type == self.OrganizationChoices.FEDERAL and self.federal_type:
|
||||
return " - ".join([org_type, self.federal_type])
|
||||
If no federal_type is found, we just return the org type.
|
||||
"""
|
||||
org_type_label = self.OrganizationChoices.get_org_label(self.organization_type)
|
||||
agency_type_label = BranchChoices.get_branch_label(self.federal_type)
|
||||
if self.organization_type == self.OrganizationChoices.FEDERAL and agency_type_label:
|
||||
return " - ".join([org_type_label, agency_type_label])
|
||||
else:
|
||||
return org_type
|
||||
return org_type_label
|
||||
|
||||
@property
|
||||
def federal_type(self):
|
||||
"""Returns the federal_type value on the underlying federal_agency field"""
|
||||
return self.federal_agency.federal_type if self.federal_agency else None
|
||||
|
||||
# == Getters for domains == #
|
||||
def get_domains(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue