mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-27 13:06:30 +02:00
Merge pull request #2392 from cisagov/gd/2365-add-suborg-to-domain-info
Ticket #2365: add suborg to domain info
This commit is contained in:
commit
5a8ac1c618
5 changed files with 131 additions and 15 deletions
|
@ -1233,7 +1233,7 @@ class DomainInformationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
search_help_text = "Search by domain."
|
search_help_text = "Search by domain."
|
||||||
|
|
||||||
fieldsets = [
|
fieldsets = [
|
||||||
(None, {"fields": ["portfolio", "creator", "submitter", "domain_request", "notes"]}),
|
(None, {"fields": ["portfolio", "sub_organization", "creator", "submitter", "domain_request", "notes"]}),
|
||||||
(".gov domain", {"fields": ["domain"]}),
|
(".gov domain", {"fields": ["domain"]}),
|
||||||
("Contacts", {"fields": ["senior_official", "other_contacts", "no_other_contacts_rationale"]}),
|
("Contacts", {"fields": ["senior_official", "other_contacts", "no_other_contacts_rationale"]}),
|
||||||
("Background info", {"fields": ["anything_else"]}),
|
("Background info", {"fields": ["anything_else"]}),
|
||||||
|
@ -1312,6 +1312,8 @@ class DomainInformationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
"senior_official",
|
"senior_official",
|
||||||
"domain",
|
"domain",
|
||||||
"submitter",
|
"submitter",
|
||||||
|
"portfolio",
|
||||||
|
"sub_organization",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Table ordering
|
# Table ordering
|
||||||
|
@ -1321,6 +1323,7 @@ class DomainInformationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
|
|
||||||
superuser_only_fields = [
|
superuser_only_fields = [
|
||||||
"portfolio",
|
"portfolio",
|
||||||
|
"sub_organization",
|
||||||
]
|
]
|
||||||
|
|
||||||
# DEVELOPER's NOTE:
|
# DEVELOPER's NOTE:
|
||||||
|
@ -1509,6 +1512,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
{
|
{
|
||||||
"fields": [
|
"fields": [
|
||||||
"portfolio",
|
"portfolio",
|
||||||
|
"sub_organization",
|
||||||
"status",
|
"status",
|
||||||
"rejection_reason",
|
"rejection_reason",
|
||||||
"action_needed_reason",
|
"action_needed_reason",
|
||||||
|
@ -1616,11 +1620,14 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
"creator",
|
"creator",
|
||||||
"senior_official",
|
"senior_official",
|
||||||
"investigator",
|
"investigator",
|
||||||
|
"portfolio",
|
||||||
|
"sub_organization",
|
||||||
]
|
]
|
||||||
filter_horizontal = ("current_websites", "alternative_domains", "other_contacts")
|
filter_horizontal = ("current_websites", "alternative_domains", "other_contacts")
|
||||||
|
|
||||||
superuser_only_fields = [
|
superuser_only_fields = [
|
||||||
"portfolio",
|
"portfolio",
|
||||||
|
"sub_organization",
|
||||||
]
|
]
|
||||||
|
|
||||||
# DEVELOPER's NOTE:
|
# DEVELOPER's NOTE:
|
||||||
|
@ -2035,14 +2042,7 @@ class DomainInformationInline(admin.StackedInline):
|
||||||
fieldsets = DomainInformationAdmin.fieldsets
|
fieldsets = DomainInformationAdmin.fieldsets
|
||||||
readonly_fields = DomainInformationAdmin.readonly_fields
|
readonly_fields = DomainInformationAdmin.readonly_fields
|
||||||
analyst_readonly_fields = DomainInformationAdmin.analyst_readonly_fields
|
analyst_readonly_fields = DomainInformationAdmin.analyst_readonly_fields
|
||||||
|
autocomplete_fields = DomainInformationAdmin.autocomplete_fields
|
||||||
autocomplete_fields = [
|
|
||||||
"creator",
|
|
||||||
"domain_request",
|
|
||||||
"senior_official",
|
|
||||||
"domain",
|
|
||||||
"submitter",
|
|
||||||
]
|
|
||||||
|
|
||||||
def has_change_permission(self, request, obj=None):
|
def has_change_permission(self, request, obj=None):
|
||||||
"""Custom has_change_permission override so that we can specify that
|
"""Custom has_change_permission override so that we can specify that
|
||||||
|
@ -2154,8 +2154,7 @@ class DomainAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# this ordering effects the ordering of results
|
# this ordering effects the ordering of results in autocomplete_fields for domain
|
||||||
# in autocomplete_fields for domain
|
|
||||||
ordering = ["name"]
|
ordering = ["name"]
|
||||||
|
|
||||||
def generic_org_type(self, obj):
|
def generic_org_type(self, obj):
|
||||||
|
@ -2639,6 +2638,11 @@ class PortfolioAdmin(ListHeaderAdmin):
|
||||||
# readonly_fields = [
|
# readonly_fields = [
|
||||||
# "requestor",
|
# "requestor",
|
||||||
# ]
|
# ]
|
||||||
|
# Creates select2 fields (with search bars)
|
||||||
|
autocomplete_fields = [
|
||||||
|
"creator",
|
||||||
|
"federal_agency",
|
||||||
|
]
|
||||||
|
|
||||||
def save_model(self, request, obj, form, change):
|
def save_model(self, request, obj, form, change):
|
||||||
|
|
||||||
|
@ -2722,6 +2726,10 @@ class DomainGroupAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
|
|
||||||
class SuborganizationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
class SuborganizationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
list_display = ["name", "portfolio"]
|
list_display = ["name", "portfolio"]
|
||||||
|
autocomplete_fields = [
|
||||||
|
"portfolio",
|
||||||
|
]
|
||||||
|
search_fields = ["name"]
|
||||||
|
|
||||||
|
|
||||||
admin.site.unregister(LogEntry) # Unregister the default registration
|
admin.site.unregister(LogEntry) # Unregister the default registration
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
# Generated by Django 4.2.10 on 2024-07-02 16:59
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("registrar", "0108_domaininformation_authorizing_official_and_more"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="domaininformation",
|
||||||
|
name="sub_organization",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
blank=True,
|
||||||
|
help_text="The suborganization that this domain is included under",
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.PROTECT,
|
||||||
|
related_name="information_sub_organization",
|
||||||
|
to="registrar.suborganization",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="domainrequest",
|
||||||
|
name="sub_organization",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
blank=True,
|
||||||
|
help_text="The suborganization that this domain request is included under",
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.PROTECT,
|
||||||
|
related_name="request_sub_organization",
|
||||||
|
to="registrar.suborganization",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="domaininformation",
|
||||||
|
name="portfolio",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
blank=True,
|
||||||
|
help_text="Portfolio associated with this domain",
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.PROTECT,
|
||||||
|
related_name="information_portfolio",
|
||||||
|
to="registrar.portfolio",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="domainrequest",
|
||||||
|
name="approved_domain",
|
||||||
|
field=models.OneToOneField(
|
||||||
|
blank=True,
|
||||||
|
help_text="Domain associated with this request; will be blank until request is approved",
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.SET_NULL,
|
||||||
|
related_name="domain_request_approved_domain",
|
||||||
|
to="registrar.domain",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="domainrequest",
|
||||||
|
name="portfolio",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
blank=True,
|
||||||
|
help_text="Portfolio associated with this domain request",
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.PROTECT,
|
||||||
|
related_name="DomainRequest_portfolio",
|
||||||
|
to="registrar.portfolio",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="domainrequest",
|
||||||
|
name="requested_domain",
|
||||||
|
field=models.OneToOneField(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.PROTECT,
|
||||||
|
related_name="domain_request_requested_domain",
|
||||||
|
to="registrar.draftdomain",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -63,10 +63,19 @@ class DomainInformation(TimeStampedModel):
|
||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
related_name="DomainRequest_portfolio",
|
related_name="information_portfolio",
|
||||||
help_text="Portfolio associated with this domain",
|
help_text="Portfolio associated with this domain",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sub_organization = models.ForeignKey(
|
||||||
|
"registrar.Suborganization",
|
||||||
|
on_delete=models.PROTECT,
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
related_name="information_sub_organization",
|
||||||
|
help_text="The suborganization that this domain is included under",
|
||||||
|
)
|
||||||
|
|
||||||
domain_request = models.OneToOneField(
|
domain_request = models.OneToOneField(
|
||||||
"registrar.DomainRequest",
|
"registrar.DomainRequest",
|
||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
|
@ -361,6 +370,10 @@ class DomainInformation(TimeStampedModel):
|
||||||
# domain_request, if so short circuit the create
|
# domain_request, if so short circuit the create
|
||||||
existing_domain_info = cls.objects.filter(domain_request__id=domain_request.id).first()
|
existing_domain_info = cls.objects.filter(domain_request__id=domain_request.id).first()
|
||||||
if existing_domain_info:
|
if existing_domain_info:
|
||||||
|
logger.info(
|
||||||
|
f"create_from_da() -> Shortcircuting create on {existing_domain_info}. "
|
||||||
|
"This record already exists. No values updated!"
|
||||||
|
)
|
||||||
return existing_domain_info
|
return existing_domain_info
|
||||||
|
|
||||||
# Get the fields that exist on both DomainRequest and DomainInformation
|
# Get the fields that exist on both DomainRequest and DomainInformation
|
||||||
|
|
|
@ -315,10 +315,19 @@ class DomainRequest(TimeStampedModel):
|
||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
related_name="DomainInformation_portfolio",
|
related_name="DomainRequest_portfolio",
|
||||||
help_text="Portfolio associated with this domain request",
|
help_text="Portfolio associated with this domain request",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sub_organization = models.ForeignKey(
|
||||||
|
"registrar.Suborganization",
|
||||||
|
on_delete=models.PROTECT,
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
related_name="request_sub_organization",
|
||||||
|
help_text="The suborganization that this domain request is included under",
|
||||||
|
)
|
||||||
|
|
||||||
# This is the domain request user who created this domain request. The contact
|
# This is the domain request user who created this domain request. The contact
|
||||||
# information that they gave is in the `submitter` field
|
# information that they gave is in the `submitter` field
|
||||||
creator = models.ForeignKey(
|
creator = models.ForeignKey(
|
||||||
|
@ -444,7 +453,7 @@ class DomainRequest(TimeStampedModel):
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
help_text="Domain associated with this request; will be blank until request is approved",
|
help_text="Domain associated with this request; will be blank until request is approved",
|
||||||
related_name="domain_request",
|
related_name="domain_request_approved_domain",
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -452,7 +461,7 @@ class DomainRequest(TimeStampedModel):
|
||||||
"DraftDomain",
|
"DraftDomain",
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
related_name="domain_request",
|
related_name="domain_request_requested_domain",
|
||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -2249,6 +2249,7 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
"action_needed_reason_email",
|
"action_needed_reason_email",
|
||||||
"federal_agency",
|
"federal_agency",
|
||||||
"portfolio",
|
"portfolio",
|
||||||
|
"sub_organization",
|
||||||
"creator",
|
"creator",
|
||||||
"investigator",
|
"investigator",
|
||||||
"generic_org_type",
|
"generic_org_type",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue