mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-16 17:47:02 +02:00
Merge remote-tracking branch 'origin/main' into nl/2300-Senior-Official-Table
This commit is contained in:
commit
ae4e435e49
22 changed files with 593 additions and 103 deletions
|
@ -598,6 +598,27 @@ class UserContactInline(admin.StackedInline):
|
|||
|
||||
model = models.Contact
|
||||
|
||||
# Read only that we'll leverage for CISA Analysts
|
||||
analyst_readonly_fields = [
|
||||
"user",
|
||||
"email",
|
||||
]
|
||||
|
||||
def get_readonly_fields(self, request, obj=None):
|
||||
"""Set the read-only state on form elements.
|
||||
We have 1 conditions that determine which fields are read-only:
|
||||
admin user permissions.
|
||||
"""
|
||||
|
||||
readonly_fields = list(self.readonly_fields)
|
||||
|
||||
if request.user.has_perm("registrar.full_access_permission"):
|
||||
return readonly_fields
|
||||
# Return restrictive Read-only fields for analysts and
|
||||
# users who might not belong to groups
|
||||
readonly_fields.extend([field for field in self.analyst_readonly_fields])
|
||||
return readonly_fields # Read-only fields for analysts
|
||||
|
||||
|
||||
class MyUserAdmin(BaseUserAdmin, ImportExportModelAdmin):
|
||||
"""Custom user admin class to use our inlines."""
|
||||
|
@ -645,7 +666,7 @@ class MyUserAdmin(BaseUserAdmin, ImportExportModelAdmin):
|
|||
None,
|
||||
{"fields": ("username", "password", "status", "verification_type")},
|
||||
),
|
||||
("Personal info", {"fields": ("first_name", "middle_name", "last_name", "title", "email", "phone")}),
|
||||
("User profile", {"fields": ("first_name", "middle_name", "last_name", "title", "email", "phone")}),
|
||||
(
|
||||
"Permissions",
|
||||
{
|
||||
|
@ -676,7 +697,7 @@ class MyUserAdmin(BaseUserAdmin, ImportExportModelAdmin):
|
|||
)
|
||||
},
|
||||
),
|
||||
("Personal Info", {"fields": ("first_name", "middle_name", "last_name", "title", "email", "phone")}),
|
||||
("User profile", {"fields": ("first_name", "middle_name", "last_name", "title", "email", "phone")}),
|
||||
(
|
||||
"Permissions",
|
||||
{
|
||||
|
@ -700,7 +721,7 @@ class MyUserAdmin(BaseUserAdmin, ImportExportModelAdmin):
|
|||
# NOT all fields are readonly for admin, otherwise we would have
|
||||
# set this at the permissions level. The exception is 'status'
|
||||
analyst_readonly_fields = [
|
||||
"Personal Info",
|
||||
"User profile",
|
||||
"first_name",
|
||||
"middle_name",
|
||||
"last_name",
|
||||
|
@ -937,6 +958,7 @@ class ContactAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
# Read only that we'll leverage for CISA Analysts
|
||||
analyst_readonly_fields = [
|
||||
"user",
|
||||
"email",
|
||||
]
|
||||
|
||||
def get_readonly_fields(self, request, obj=None):
|
||||
|
@ -1246,7 +1268,7 @@ class DomainInformationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
search_help_text = "Search by domain."
|
||||
|
||||
fieldsets = [
|
||||
(None, {"fields": ["portfolio", "creator", "submitter", "domain_request", "notes"]}),
|
||||
(None, {"fields": ["portfolio", "sub_organization", "creator", "submitter", "domain_request", "notes"]}),
|
||||
(".gov domain", {"fields": ["domain"]}),
|
||||
("Contacts", {"fields": ["senior_official", "other_contacts", "no_other_contacts_rationale"]}),
|
||||
("Background info", {"fields": ["anything_else"]}),
|
||||
|
@ -1325,6 +1347,8 @@ class DomainInformationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
"senior_official",
|
||||
"domain",
|
||||
"submitter",
|
||||
"portfolio",
|
||||
"sub_organization",
|
||||
]
|
||||
|
||||
# Table ordering
|
||||
|
@ -1334,6 +1358,7 @@ class DomainInformationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
|
||||
superuser_only_fields = [
|
||||
"portfolio",
|
||||
"sub_organization",
|
||||
]
|
||||
|
||||
# DEVELOPER's NOTE:
|
||||
|
@ -1522,6 +1547,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
{
|
||||
"fields": [
|
||||
"portfolio",
|
||||
"sub_organization",
|
||||
"status",
|
||||
"rejection_reason",
|
||||
"action_needed_reason",
|
||||
|
@ -1629,11 +1655,14 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
"creator",
|
||||
"senior_official",
|
||||
"investigator",
|
||||
"portfolio",
|
||||
"sub_organization",
|
||||
]
|
||||
filter_horizontal = ("current_websites", "alternative_domains", "other_contacts")
|
||||
|
||||
superuser_only_fields = [
|
||||
"portfolio",
|
||||
"sub_organization",
|
||||
]
|
||||
|
||||
# DEVELOPER's NOTE:
|
||||
|
@ -2048,14 +2077,7 @@ class DomainInformationInline(admin.StackedInline):
|
|||
fieldsets = DomainInformationAdmin.fieldsets
|
||||
readonly_fields = DomainInformationAdmin.readonly_fields
|
||||
analyst_readonly_fields = DomainInformationAdmin.analyst_readonly_fields
|
||||
|
||||
autocomplete_fields = [
|
||||
"creator",
|
||||
"domain_request",
|
||||
"senior_official",
|
||||
"domain",
|
||||
"submitter",
|
||||
]
|
||||
autocomplete_fields = DomainInformationAdmin.autocomplete_fields
|
||||
|
||||
def has_change_permission(self, request, obj=None):
|
||||
"""Custom has_change_permission override so that we can specify that
|
||||
|
@ -2167,8 +2189,7 @@ class DomainAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
),
|
||||
)
|
||||
|
||||
# this ordering effects the ordering of results
|
||||
# in autocomplete_fields for domain
|
||||
# this ordering effects the ordering of results in autocomplete_fields for domain
|
||||
ordering = ["name"]
|
||||
|
||||
def generic_org_type(self, obj):
|
||||
|
@ -2652,6 +2673,11 @@ class PortfolioAdmin(ListHeaderAdmin):
|
|||
# readonly_fields = [
|
||||
# "requestor",
|
||||
# ]
|
||||
# Creates select2 fields (with search bars)
|
||||
autocomplete_fields = [
|
||||
"creator",
|
||||
"federal_agency",
|
||||
]
|
||||
|
||||
def save_model(self, request, obj, form, change):
|
||||
|
||||
|
@ -2735,6 +2761,10 @@ class DomainGroupAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
|
||||
class SuborganizationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||
list_display = ["name", "portfolio"]
|
||||
autocomplete_fields = [
|
||||
"portfolio",
|
||||
]
|
||||
search_fields = ["name"]
|
||||
|
||||
|
||||
admin.site.unregister(LogEntry) # Unregister the default registration
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue