Skip to content

Commit

Permalink
Merge pull request #2046 from cisagov/rh/2909-new-agency-field
Browse files Browse the repository at this point in the history
ISSUE #2029: Add new model for new federal agency field
  • Loading branch information
therealslimhsiehdy authored Apr 19, 2024
2 parents 61e6206 + 02861c2 commit 564537c
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/registrar/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,9 @@ class DomainInformationAdmin(ListHeaderAdmin):
"classes": ["collapse"],
"fields": [
"federal_type",
"federal_agency",
# "updated_federal_agency",
# Above field commented out so it won't display
"federal_agency", # TODO: remove later
"tribe_name",
"federally_recognized_tribe",
"state_recognized_tribe",
Expand Down Expand Up @@ -1218,7 +1220,9 @@ def custom_election_board(self, obj):
"classes": ["collapse"],
"fields": [
"federal_type",
"federal_agency",
# "updated_federal_agency",
# Above field commented out so it won't display
"federal_agency", # TODO: remove later
"tribe_name",
"federally_recognized_tribe",
"state_recognized_tribe",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 4.2.10 on 2024-04-18 22:45

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("registrar", "0085_alter_contact_first_name_alter_contact_last_name_and_more"),
]

operations = [
migrations.AddField(
model_name="domaininformation",
name="updated_federal_agency",
field=models.ForeignKey(
blank=True,
help_text="Associated federal agency",
null=True,
on_delete=django.db.models.deletion.PROTECT,
to="registrar.federalagency",
),
),
migrations.AddField(
model_name="domainrequest",
name="updated_federal_agency",
field=models.ForeignKey(
blank=True,
help_text="Associated federal agency",
null=True,
on_delete=django.db.models.deletion.PROTECT,
to="registrar.federalagency",
),
),
]
10 changes: 10 additions & 0 deletions src/registrar/models/domain_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,18 @@ class DomainInformation(TimeStampedModel):

BranchChoices = DomainRequest.BranchChoices

# TODO for #1975: Delete this after we run the new migration
AGENCY_CHOICES = DomainRequest.AGENCY_CHOICES

updated_federal_agency = models.ForeignKey(
"registrar.FederalAgency",
on_delete=models.PROTECT,
help_text="Associated federal agency",
unique=False,
blank=True,
null=True,
)

# This is the domain request user who created this domain request. The contact
# information that they gave is in the `submitter` field
creator = models.ForeignKey(
Expand Down
9 changes: 9 additions & 0 deletions src/registrar/models/domain_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,15 @@ class RejectionReasons(models.TextChoices):
blank=True,
)

updated_federal_agency = models.ForeignKey(
"registrar.FederalAgency",
on_delete=models.PROTECT,
help_text="Associated federal agency",
unique=False,
blank=True,
null=True,
)

# This is the domain request user who created this domain request. The contact
# information that they gave is in the `submitter` field
creator = models.ForeignKey(
Expand Down
2 changes: 2 additions & 0 deletions src/registrar/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1862,6 +1862,8 @@ def test_readonly_when_restricted_creator(self):
"updated_at",
"status",
"rejection_reason",
"updated_federal_agency",
# TODO: once approved, we'll have to remove above from test
"creator",
"investigator",
"generic_org_type",
Expand Down

0 comments on commit 564537c

Please sign in to comment.