From b61e58bcdcd2f6178a40f1861175fc3239933282 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 9 Nov 2023 14:30:00 -0700 Subject: [PATCH 01/10] Initial --- .../transfer_transition_domains_to_domains.py | 13 +++- .../utility/extra_transition_domain_helper.py | 65 ++++++++++++++++++- ...il_transitiondomain_first_name_and_more.py | 48 ++++++++++++++ src/registrar/models/transition_domain.py | 38 ++++++++++- 4 files changed, 158 insertions(+), 6 deletions(-) create mode 100644 src/registrar/migrations/0046_transitiondomain_email_transitiondomain_first_name_and_more.py 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" ) From 0d749303dcfa023e326be0252e37d0d0ccd7570f Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 9 Nov 2023 15:50:42 -0700 Subject: [PATCH 02/10] Update transfer_transition_domains_to_domains.py --- .../transfer_transition_domains_to_domains.py | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) 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 2ad62b307..277e28687 100644 --- a/src/registrar/management/commands/transfer_transition_domains_to_domains.py +++ b/src/registrar/management/commands/transfer_transition_domains_to_domains.py @@ -14,6 +14,7 @@ from registrar.management.commands.utility.terminal_helper import ( TerminalColors, TerminalHelper, ) +from registrar.models.contact import Contact from registrar.models.domain_application import DomainApplication from registrar.models.domain_information import DomainInformation from registrar.models.user import User @@ -387,7 +388,25 @@ class Command(BaseCommand): last_name = transition_domain.last_name email = transition_domain.email phone = transition_domain.phone - + + contact = None + contacts = Contact.objects.filter(email=email) + contact_count = contacts.count() + # Create a new one + if contact_count == 0: + contact = Contact( + first_name=first_name, + middle_name=middle_name, + last_name=last_name, + email=email, + phone=phone + ) + contact.save() + elif contact_count == 1: + # TODO + contact = contacts.get() + else: + logger.error("duplicates found") org_type_current = transition_domain.organization_type match org_type_current: @@ -416,7 +435,7 @@ class Command(BaseCommand): "domain": domain, "organization_name": transition_domain.organization_name, "creator": default_creator, - "authorizing_official": + "authorizing_official": contact } if valid_org_type: From 51b4c19e3571fafd5ca58e01ada185e3a083f5ad Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 13 Nov 2023 11:54:40 -0700 Subject: [PATCH 03/10] Fix merge issue --- .../commands/utility/extra_transition_domain_helper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 20c8293e5..24cc503cd 100644 --- a/src/registrar/management/commands/utility/extra_transition_domain_helper.py +++ b/src/registrar/management/commands/utility/extra_transition_domain_helper.py @@ -170,7 +170,10 @@ class LoadExtraTransitionDomain: # STEP 3: Parse agency data updated_transition_domain = self.parse_agency_data(domain_name, transition_domain) - # STEP 4: Parse creation and expiration data + # STEP 4: Parse ao data + updated_transition_domain = self.parse_authority_data(domain_name, transition_domain) + + # STEP 5: Parse creation and expiration data updated_transition_domain = self.parse_creation_expiration_data(domain_name, transition_domain) # Check if the instance has changed before saving From a4758f1b621da621972e4cf7c423dbf96eb279e4 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 13 Nov 2023 13:08:03 -0700 Subject: [PATCH 04/10] Parse AO information --- .../transfer_transition_domains_to_domains.py | 27 ++++++++++++++----- .../tests/data/test_authority_adhoc.txt | 4 +-- .../test_transition_domain_migrations.py | 8 ++++++ 3 files changed, 30 insertions(+), 9 deletions(-) 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 58b36c1e5..c5b1c1ebd 100644 --- a/src/registrar/management/commands/transfer_transition_domains_to_domains.py +++ b/src/registrar/management/commands/transfer_transition_domains_to_domains.py @@ -2,7 +2,7 @@ import logging import argparse import sys -from django_fsm import TransitionNotAllowed # type: ignore +from django.forms import ValidationError from django.core.management import BaseCommand @@ -345,9 +345,6 @@ class Command(BaseCommand): return updated - def try_add_domain_information(self): - pass - def create_new_domain_info( self, transition_domain: TransitionDomain, @@ -382,11 +379,27 @@ class Command(BaseCommand): ) contact.save() elif contact_count == 1: - # TODO contact = contacts.get() + contact.first_name = first_name + contact.middle_name = middle_name + contact.last_name = last_name + contact.email = email + contact.phone = phone + contact.save() else: - logger.error("duplicates found") - + logger.warning(f"Duplicate contact found {contact}. Updating all relevant entries.") + for c in contact: + c.first_name = first_name + c.middle_name = middle_name + c.last_name = last_name + c.email = email + c.phone = phone + c.save() + contact = c.first() + + if debug_on: + logger.info(f"Contact created: {contact}") + org_type_current = transition_domain.organization_type match org_type_current: case "Federal": diff --git a/src/registrar/tests/data/test_authority_adhoc.txt b/src/registrar/tests/data/test_authority_adhoc.txt index 01e1a97db..3665182cd 100644 --- a/src/registrar/tests/data/test_authority_adhoc.txt +++ b/src/registrar/tests/data/test_authority_adhoc.txt @@ -2,5 +2,5 @@ authorityid|firstname|middlename|lastname|email|phonenumber|agencyid|addlinfo 1|Gregoor|middle|Kalinke|gkalinke0@indiegogo.com|(773) 172-5515|1|Asparagus - Mexican 2|Fayre||Filippozzi|ffilippozzi1@hugedomains.com|(357) 487-4280|2|Steampan - Foil 3|Gabey||Lightbody|glightbody2@fc2.com|(332) 816-5691|3|Soup - Campbells, Minestrone -4|Seline||Tower|stower3@answers.com|(151) 539-6028|4|Kiwi Gold Zespri -5|Joe||Smoe|joe@smoe.gov|(111) 111-1111|5|Kiwi Gold Zespri \ No newline at end of file +4|Seline|testmiddle2|Tower|stower3@answers.com|151-539-6028|4|Kiwi Gold Zespri +5|Joe|testmiddle|Smoe|joe@smoe.gov|(111) 111-1111|5|Kiwi Gold Zespri \ No newline at end of file diff --git a/src/registrar/tests/test_transition_domain_migrations.py b/src/registrar/tests/test_transition_domain_migrations.py index 5c93fd8f0..c6418f013 100644 --- a/src/registrar/tests/test_transition_domain_migrations.py +++ b/src/registrar/tests/test_transition_domain_migrations.py @@ -313,6 +313,14 @@ class TestMigrations(TestCase): self.assertEqual(fakewebsite.federal_agency, "Department of Commerce") self.assertEqual(fakewebsite.federal_type, "executive") + ao = fakewebsite.authorizing_official + + self.assertEqual(ao.first_name, "Seline") + self.assertEqual(ao.middle_name, "testmiddle2") + self.assertEqual(ao.last_name, "Tower") + self.assertEqual(ao.email, "stower3@answers.com") + self.assertEqual(ao.phone, "151-539-6028") + # Check for the "system" creator user Users = User.objects.filter(username="System") self.assertEqual(Users.count(), 1) From 674fc9f7b3366ddeca65bec236c3b2cc8137828e Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 13 Nov 2023 13:09:42 -0700 Subject: [PATCH 05/10] Update transfer_transition_domains_to_domains.py --- .../commands/transfer_transition_domains_to_domains.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c5b1c1ebd..b1bf22472 100644 --- a/src/registrar/management/commands/transfer_transition_domains_to_domains.py +++ b/src/registrar/management/commands/transfer_transition_domains_to_domains.py @@ -2,7 +2,7 @@ import logging import argparse import sys -from django.forms import ValidationError +from django_fsm import TransitionNotAllowed # type: ignore from django.core.management import BaseCommand From 82fc67025b815adc1196dfb784ef8d56efd20092 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 13 Nov 2023 13:29:06 -0700 Subject: [PATCH 06/10] Linting --- .../transfer_transition_domains_to_domains.py | 10 +++------- .../utility/extra_transition_domain_helper.py | 11 ++--------- src/registrar/models/transition_domain.py | 1 + 3 files changed, 6 insertions(+), 16 deletions(-) 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 b1bf22472..936026737 100644 --- a/src/registrar/management/commands/transfer_transition_domains_to_domains.py +++ b/src/registrar/management/commands/transfer_transition_domains_to_domains.py @@ -367,15 +367,11 @@ class Command(BaseCommand): contact = None contacts = Contact.objects.filter(email=email) - contact_count = contacts.count() + contact_count = contacts.count() # Create a new one if contact_count == 0: contact = Contact( - first_name=first_name, - middle_name=middle_name, - last_name=last_name, - email=email, - phone=phone + first_name=first_name, middle_name=middle_name, last_name=last_name, email=email, phone=phone ) contact.save() elif contact_count == 1: @@ -427,7 +423,7 @@ class Command(BaseCommand): "domain": domain, "organization_name": transition_domain.organization_name, "creator": default_creator, - "authorizing_official": contact + "authorizing_official": contact, } 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 24cc503cd..3261a0ff9 100644 --- a/src/registrar/management/commands/utility/extra_transition_domain_helper.py +++ b/src/registrar/management/commands/utility/extra_transition_domain_helper.py @@ -287,10 +287,7 @@ class LoadExtraTransitionDomain: 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() != "" - ) + 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( @@ -331,11 +328,7 @@ class LoadExtraTransitionDomain: ("email", transition_domain.email), ("phone", transition_domain.phone), ] - self.log_add_or_changed_values( - EnumFilenames.AUTHORITY_ADHOC, - changed_fields, - domain_name - ) + self.log_add_or_changed_values(EnumFilenames.AUTHORITY_ADHOC, changed_fields, domain_name) return transition_domain diff --git a/src/registrar/models/transition_domain.py b/src/registrar/models/transition_domain.py index bae07d18f..3f1c8d641 100644 --- a/src/registrar/models/transition_domain.py +++ b/src/registrar/models/transition_domain.py @@ -1,6 +1,7 @@ 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" From 6f729ff69369268fd2909bd1b06225f410f4bfc9 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 13 Nov 2023 13:37:58 -0700 Subject: [PATCH 07/10] Update extra_transition_domain_helper.py --- .../commands/utility/extra_transition_domain_helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3261a0ff9..7961b47c1 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, List +from typing import Dict from registrar.models.transition_domain import TransitionDomain From 1b5ecc8e52f689a017e69e37f29e2d780c58ea03 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:34:51 -0700 Subject: [PATCH 08/10] Fixes / linter --- .../transfer_transition_domains_to_domains.py | 44 ++++++++++--------- src/registrar/utility/csv_export.py | 2 +- 2 files changed, 25 insertions(+), 21 deletions(-) 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 936026737..8db2e5ed9 100644 --- a/src/registrar/management/commands/transfer_transition_domains_to_domains.py +++ b/src/registrar/management/commands/transfer_transition_domains_to_domains.py @@ -345,26 +345,7 @@ class Command(BaseCommand): return updated - def create_new_domain_info( - self, - transition_domain: TransitionDomain, - domain: Domain, - agency_choices, - fed_choices, - org_choices, - debug_on, - ) -> DomainInformation: - org_type = ("", "") - fed_type = transition_domain.federal_type - fed_agency = transition_domain.federal_agency - - # = 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 - + def update_contact_info(self, first_name, middle_name, last_name, email, phone): contact = None contacts = Contact.objects.filter(email=email) contact_count = contacts.count() @@ -392,6 +373,29 @@ class Command(BaseCommand): c.phone = phone c.save() contact = c.first() + return contact + + def create_new_domain_info( + self, + transition_domain: TransitionDomain, + domain: Domain, + agency_choices, + fed_choices, + org_choices, + debug_on, + ) -> DomainInformation: + org_type = ("", "") + fed_type = transition_domain.federal_type + fed_agency = transition_domain.federal_agency + + # = 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 + + contact = self.update_contact_info(first_name, middle_name, last_name, email, phone) if debug_on: logger.info(f"Contact created: {contact}") diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index f1062307f..55bb0af3c 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -24,7 +24,7 @@ def export_domains_to_writer(writer, columns, sort_fields, filter_condition): "Organization name": domainInfo.organization_name, "City": domainInfo.city, "State": domainInfo.state_territory, - "AO": domainInfo.authorizing_official.first_name + " " + domainInfo.authorizing_official.last_name + "AO": (domainInfo.authorizing_official.first_name or "") + " " + (domainInfo.authorizing_official.last_name or "") if domainInfo.authorizing_official else " ", "AO email": domainInfo.authorizing_official.email if domainInfo.authorizing_official else " ", From 86dbe6b6a0b7c231ad7b718378900febd162ad35 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:40:03 -0700 Subject: [PATCH 09/10] Update csv_export.py --- src/registrar/utility/csv_export.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index 55bb0af3c..6b5b64a7f 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -13,7 +13,9 @@ def export_domains_to_writer(writer, columns, sort_fields, filter_condition): domainInfos = DomainInformation.objects.filter(**filter_condition).order_by(*sort_fields) for domainInfo in domainInfos: security_contacts = domainInfo.domain.contacts.filter(contact_type=PublicContact.ContactTypeChoices.SECURITY) - + ao = ( + (domainInfo.authorizing_official.first_name or "") + " " + (domainInfo.authorizing_official.last_name or "") + ) # create a dictionary of fields which can be included in output FIELDS = { "Domain name": domainInfo.domain.name, @@ -24,9 +26,7 @@ def export_domains_to_writer(writer, columns, sort_fields, filter_condition): "Organization name": domainInfo.organization_name, "City": domainInfo.city, "State": domainInfo.state_territory, - "AO": (domainInfo.authorizing_official.first_name or "") + " " + (domainInfo.authorizing_official.last_name or "") - if domainInfo.authorizing_official - else " ", + "AO": ao if domainInfo.authorizing_official else " ", "AO email": domainInfo.authorizing_official.email if domainInfo.authorizing_official else " ", "Security Contact Email": security_contacts[0].email if security_contacts else " ", "Status": domainInfo.domain.state, From 0d64d9f0406b61dec24d2a0c8ab6f6cfa97e7217 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:53:19 -0700 Subject: [PATCH 10/10] Update csv_export.py --- src/registrar/utility/csv_export.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index 6b5b64a7f..64136c3a5 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -13,9 +13,12 @@ def export_domains_to_writer(writer, columns, sort_fields, filter_condition): domainInfos = DomainInformation.objects.filter(**filter_condition).order_by(*sort_fields) for domainInfo in domainInfos: security_contacts = domainInfo.domain.contacts.filter(contact_type=PublicContact.ContactTypeChoices.SECURITY) - ao = ( - (domainInfo.authorizing_official.first_name or "") + " " + (domainInfo.authorizing_official.last_name or "") - ) + # For linter + ao = " " + if domainInfo.authorizing_official: + first_name = domainInfo.authorizing_official.first_name or "" + last_name = domainInfo.authorizing_official.last_name or "" + ao = first_name + " " + last_name # create a dictionary of fields which can be included in output FIELDS = { "Domain name": domainInfo.domain.name, @@ -26,7 +29,7 @@ def export_domains_to_writer(writer, columns, sort_fields, filter_condition): "Organization name": domainInfo.organization_name, "City": domainInfo.city, "State": domainInfo.state_territory, - "AO": ao if domainInfo.authorizing_official else " ", + "AO": ao, "AO email": domainInfo.authorizing_official.email if domainInfo.authorizing_official else " ", "Security Contact Email": security_contacts[0].email if security_contacts else " ", "Status": domainInfo.domain.state,