diff --git a/src/registrar/management/commands/transfer_transition_domains_to_domains.py b/src/registrar/management/commands/transfer_transition_domains_to_domains.py index 0b64788cd..2ad62b307 100644 --- a/src/registrar/management/commands/transfer_transition_domains_to_domains.py +++ b/src/registrar/management/commands/transfer_transition_domains_to_domains.py @@ -377,11 +377,19 @@ class Command(BaseCommand): org_choices, debug_on, ) -> DomainInformation: - org_type_current = transition_domain.organization_type + org_type = ("", "") fed_type = transition_domain.federal_type fed_agency = transition_domain.federal_agency - org_type = ("", "") + # = AO Information = # + first_name = transition_domain.first_name + middle_name = transition_domain.middle_name + last_name = transition_domain.last_name + email = transition_domain.email + phone = transition_domain.phone + + + org_type_current = transition_domain.organization_type match org_type_current: case "Federal": org_type = ("federal", "Federal") @@ -408,6 +416,7 @@ class Command(BaseCommand): "domain": domain, "organization_name": transition_domain.organization_name, "creator": default_creator, + "authorizing_official": } if valid_org_type: diff --git a/src/registrar/management/commands/utility/extra_transition_domain_helper.py b/src/registrar/management/commands/utility/extra_transition_domain_helper.py index 89e50742e..2e71ae600 100644 --- a/src/registrar/management/commands/utility/extra_transition_domain_helper.py +++ b/src/registrar/management/commands/utility/extra_transition_domain_helper.py @@ -9,7 +9,7 @@ import logging import os import sys -from typing import Dict +from typing import Dict, List from registrar.models.transition_domain import TransitionDomain @@ -175,12 +175,17 @@ class LoadExtraTransitionDomain: domain_name, transition_domain ) - # STEP 3: Parse agency data + # STEP 3: Parse authority data + updated_transition_domain = self.parse_authority_data( + domain_name, transition_domain + ) + + # STEP 4: Parse agency data updated_transition_domain = self.parse_agency_data( domain_name, transition_domain ) - # STEP 4: Parse creation and expiration data + # STEP 5: Parse creation and expiration data updated_transition_domain = self.parse_creation_expiration_data( domain_name, transition_domain ) @@ -299,6 +304,60 @@ class LoadExtraTransitionDomain: return transition_domain + def log_add_or_changed_values(self, file_type, values_to_check, domain_name): + for field_name, value in values_to_check: + str_exists = ( + value is not None + and value.strip() != "" + ) + # Logs if we either added to this property, + # or modified it. + self._add_or_change_message( + file_type, + field_name, + value, + domain_name, + str_exists, + ) + + def parse_authority_data(self, domain_name, transition_domain) -> TransitionDomain: + """Grabs authorizing_offical data from the parsed files and associates it + with a transition_domain object, then returns that object.""" + if not isinstance(transition_domain, TransitionDomain): + raise ValueError("Not a valid object, must be TransitionDomain") + + info = self.get_authority_info(domain_name) + if info is None: + self.parse_logs.create_log_item( + EnumFilenames.AGENCY_ADHOC, + LogCode.ERROR, + f"Could not add authorizing_official on {domain_name}, no data exists.", + domain_name, + not self.debug, + ) + return transition_domain + + transition_domain.first_name = info.firstname + transition_domain.middle_name = info.middlename + transition_domain.last_name = info.lastname + transition_domain.email = info.email + transition_domain.phone = info.phonenumber + + changed_fields = [ + ("first_name", transition_domain.first_name), + ("middle_name", transition_domain.middle_name), + ("last_name", transition_domain.last_name), + ("email", transition_domain.email), + ("phone", transition_domain.phone), + ] + self.log_add_or_changed_values( + EnumFilenames.AUTHORITY_ADHOC, + changed_fields, + domain_name + ) + + return transition_domain + def parse_agency_data(self, domain_name, transition_domain) -> TransitionDomain: """Grabs federal_agency from the parsed files and associates it with a transition_domain object, then returns that object.""" diff --git a/src/registrar/migrations/0046_transitiondomain_email_transitiondomain_first_name_and_more.py b/src/registrar/migrations/0046_transitiondomain_email_transitiondomain_first_name_and_more.py new file mode 100644 index 000000000..4fcb66713 --- /dev/null +++ b/src/registrar/migrations/0046_transitiondomain_email_transitiondomain_first_name_and_more.py @@ -0,0 +1,48 @@ +# Generated by Django 4.2.7 on 2023-11-09 19:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("registrar", "0045_transitiondomain_federal_agency_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="transitiondomain", + name="email", + field=models.TextField(blank=True, help_text="Email", null=True), + ), + migrations.AddField( + model_name="transitiondomain", + name="first_name", + field=models.TextField( + blank=True, + db_index=True, + help_text="First name", + null=True, + verbose_name="first name / given name", + ), + ), + migrations.AddField( + model_name="transitiondomain", + name="last_name", + field=models.TextField(blank=True, help_text="Last name", null=True), + ), + migrations.AddField( + model_name="transitiondomain", + name="middle_name", + field=models.TextField(blank=True, help_text="Middle name", null=True), + ), + migrations.AddField( + model_name="transitiondomain", + name="phone", + field=models.TextField(blank=True, help_text="Phone", null=True), + ), + migrations.AddField( + model_name="transitiondomain", + name="title", + field=models.TextField(blank=True, help_text="Title", null=True), + ), + ] diff --git a/src/registrar/models/transition_domain.py b/src/registrar/models/transition_domain.py index 7c4d2afe2..d1283f1ee 100644 --- a/src/registrar/models/transition_domain.py +++ b/src/registrar/models/transition_domain.py @@ -1,7 +1,6 @@ from django.db import models from .utility.time_stamped_model import TimeStampedModel - class StatusChoices(models.TextChoices): READY = "ready", "Ready" ON_HOLD = "on hold", "On Hold" @@ -77,6 +76,38 @@ class TransitionDomain(TimeStampedModel): "Duplication of registry's expiration " "date saved for ease of reporting" ), ) + first_name = models.TextField( + null=True, + blank=True, + help_text="First name", + verbose_name="first name / given name", + db_index=True, + ) + middle_name = models.TextField( + null=True, + blank=True, + help_text="Middle name", + ) + last_name = models.TextField( + null=True, + blank=True, + help_text="Last name", + ) + title = models.TextField( + null=True, + blank=True, + help_text="Title", + ) + email = models.TextField( + null=True, + blank=True, + help_text="Email", + ) + phone = models.TextField( + null=True, + blank=True, + help_text="Phone", + ) def __str__(self): return f"{self.username}, {self.domain_name}" @@ -95,4 +126,9 @@ class TransitionDomain(TimeStampedModel): f"federal_agency: {self.federal_agency}, \n" f"epp_creation_date: {self.epp_creation_date}, \n" f"epp_expiration_date: {self.epp_expiration_date}, \n" + f"first_name: {self.first_name}, \n" + f"middle_name: {self.middle_name}, \n" + f"last_name: {self.last_name}, \n" + f"email: {self.email}, \n" + f"phone: {self.phone}, \n" )