Fine tuning

This commit is contained in:
zandercymatics 2024-06-26 10:07:19 -06:00
parent 5d68031dce
commit 4c3404b885
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
4 changed files with 40 additions and 4 deletions

View file

@ -1233,7 +1233,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": ["authorizing_official", "other_contacts", "no_other_contacts_rationale"]}),
("Background info", {"fields": ["anything_else"]}),
@ -1510,6 +1510,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
{
"fields": [
"portfolio",
"sub_organization",
"status",
"rejection_reason",
"action_needed_reason",
@ -2645,6 +2646,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):
@ -2728,6 +2734,9 @@ class DomainGroupAdmin(ListHeaderAdmin, ImportExportModelAdmin):
class SuborganizationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
list_display = ["name", "portfolio"]
autocomplete_fields = [
"portfolio",
]
admin.site.unregister(LogEntry) # Unregister the default registration

View file

@ -1,4 +1,4 @@
# Generated by Django 4.2.10 on 2024-06-26 15:34
# Generated by Django 4.2.10 on 2024-06-26 16:07
from django.db import migrations, models
import django.db.models.deletion
@ -47,6 +47,18 @@ class Migration(migrations.Migration):
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",
@ -59,4 +71,15 @@ class Migration(migrations.Migration):
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",
),
),
]

View file

@ -370,6 +370,10 @@ class DomainInformation(TimeStampedModel):
# domain_request, if so short circuit the create
existing_domain_info = cls.objects.filter(domain_request__id=domain_request.id).first()
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
# Get the fields that exist on both DomainRequest and DomainInformation

View file

@ -449,7 +449,7 @@ class DomainRequest(TimeStampedModel):
null=True,
blank=True,
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,
)
@ -457,7 +457,7 @@ class DomainRequest(TimeStampedModel):
"DraftDomain",
null=True,
blank=True,
related_name="domain_request",
related_name="domain_request_requested_domain",
on_delete=models.PROTECT,
)