Make senior official readonly

This commit is contained in:
zandercymatics 2024-09-26 09:49:14 -06:00
parent 2430d3ecf6
commit 02bf9c4781
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
4 changed files with 51 additions and 24 deletions

View file

@ -2982,6 +2982,8 @@ class PortfolioAdmin(ListHeaderAdmin):
"display_admins",
"display_members",
"creator",
# As of now this means that only federal agency can update this, but this will change.
"senior_official",
]
analyst_readonly_fields = [
@ -3208,6 +3210,11 @@ class PortfolioAdmin(ListHeaderAdmin):
is_federal = obj.organization_type == DomainRequest.OrganizationChoices.FEDERAL
if is_federal and obj.organization_name is None:
obj.organization_name = obj.federal_agency.agency
# Remove this line when senior_official is no longer readonly in /admin.
if obj.federal_agency and obj.federal_agency.so_federal_agency.exists():
obj.senior_official = obj.federal_agency.so_federal_agency.first()
super().save_model(request, obj, form, change)