Skip to content

#3618: script to update public contact org city state#4623

Merged
chaswick merged 28 commits into
mainfrom
cw/3618-script-to-update-public-contact-org-city-state
Apr 23, 2026
Merged

#3618: script to update public contact org city state#4623
chaswick merged 28 commits into
mainfrom
cw/3618-script-to-update-public-contact-org-city-state

Conversation

@chaswick
Copy link
Copy Markdown
Contributor

@chaswick chaswick commented Jan 29, 2026

Ticket

Resolves #3618

Changes

Context for reviewers

Setup

This is a python django management command (https://docs.djangoproject.com/en/6.0/ref/django-admin/) and can be run from the sandbox environment where it is deployed using the cf login process defined in the Master Engineering Document -> Development -> Sandboxes section.

The basic run command is 'python manage.py update_public_contact_disclosure_settings'. Running this will print helpful instructions for the required option parameters.

`vcap@ac8d6e78-76b7-4f9a-6a17-553b:~$ python manage.py update_public_contact_disclosure_settings --help
[20/Apr/2026 20:13:25] INFO [epplibwrapper.client:198] registry client initialized
usage: manage.py update_public_contact_disclosure_settings [-h] [--target-domain TARGET_DOMAIN]
                                                           [--dry-run | --no-dry-run | --dry_run | --no-dry_run]
                                                           [--use-recovery-log | --no-use-recovery-log | --use_recovery_log | --no-use_recovery_log]
                                                           [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH]
                                                           [--traceback] [--no-color] [--force-color] [--skip-checks]

Updates registry disclose settings and field values for PublicContact records to whatever the website currently computes (for example, portfolio relationships).

options:
  -h, --help            show this help message and exit
  --target-domain TARGET_DOMAIN, --target_domain TARGET_DOMAIN
                        Only update contacts for a given domain name (case insensitive).
  --dry-run, --no-dry-run, --dry_run, --no-dry_run
                        When enabled (which is the default), does not call the registry; only reports what would be updated. Disable with --no-
                        dry-run to perform updates. (default: True)
  --use-recovery-log, --no-use-recovery-log, --use_recovery_log, --no-use_recovery_log
                        When enabled, use the recovery log text file to skip domains that were marked 'done'. (default: False)
  --version             Show program's version number and exit.
  -v {0,1,2,3}, --verbosity {0,1,2,3}
                        Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
  --settings SETTINGS   The Python path to a settings module, e.g. "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be used.
  --pythonpath PYTHONPATH
                        A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".
  --traceback           Raise on CommandError exceptions.
  --no-color            Don't colorize the command output.
  --force-color         Force colorization of the command output.
  --skip-checks         Skip system checks.
`

Note that to make actual changes --no-dry-run must be passed. An example would be: python manage.py update_public_contact_disclosure_settings --target-domain charlie-example.gov --no-dry-run Make sure to respond to the prompt.

  1. We want to test that when specifying a specific target domain, the public contact disclosure settings are updated to match the requirements (review Connect "public contact" values for Registrant to actual registrant values #3580 for discussion and implementation of requirements).
  2. We also want to verify that for registrant contact types that belong to a portfolio, the possibly inherited fields (again refer to 3580 addRegistrant method for the logic) should be applied if necsessary.
  3. In order to test this you will have to create/modify public contacts, domains and portfolios in the sandbox in order to create necessary relationships such as:
  • Domains not attached to Portfolios:
    Registrant public contact types contain proper disclosure fields. Refer to 3580 for specifics.
  • Domains attached to portfolios
    Registrant public contact types contain proper disclosure fields. Refer to 3580 for specifics.
    • Registrant fields such as address, name, etc contain values which match their inherited portfolio
    • a update_public_contacts_recovery_log.txt exists when --no-dry-run is specified
    • using --use-recovery-log uses the contents of the file as input and does carry out updates.

You will have to use the cf ote registry to verify these updates were carried out, and the manage.get.gov sandbox to verify the setup and relationships of the data.

Code Review Verification Steps

As the original developer, I have

Satisfied acceptance criteria and met development standards

  • Met the acceptance criteria, or will meet them in a subsequent PR
  • Created/modified automated tests
  • Update documentation in READMEs and/or onboarding guide

Ensured code standards are met (Original Developer)

  • If any updated dependencies on Pipfile, also update dependencies in requirements.txt.
  • Interactions with external systems are wrapped in try/except
  • Error handling exists for unusual or missing values

Validated user-facing changes (if applicable)

  • Follow the process for requesting a design review. If code is not user-facing, delete design reviewer checklist
  • Verify new pages have been added to .pa11yci file so that they will be tested with our automated accessibility testing
  • Checked keyboard navigability
  • screen reader (such as NVDA with Chrome or Voiceover with Safari):
    • Tested general usability
    • landmarks
    • page header structure
    • links
  • Checked for errors or warnings with an a11y browser tool (such as ANDI or WAVE)

As a code reviewer, I have

Reviewed, tested, and left feedback about the changes

  • Pulled this branch locally and tested it
  • Verified code meets all checks above. Address any checks that are not satisfied
  • Reviewed this code and left comments. Indicate if comments must be addressed before code is merged
  • Checked that all code is adequately covered by tests
  • Verify migrations are valid and do not conflict with existing migrations

Validated user-facing changes as a developer

Note: Multiple code reviewers can share the checklists above, a second reviewer should not make a duplicate checklist. All checks should be checked before approving, even those labeled N/A.

  • New pages have been added to .pa11yci file so that they will be tested with our automated accessibility testing
  • Checked keyboard navigability
  • Meets all designs and user flows provided by design/product
  • screen reader (such as NVDA with Chrome or Voiceover with Safari):
    • Tested general usability
    • landmarks
    • page header structure
    • links
  • Checked for errors or warnings with an a11y browser tool (such as ANDI or WAVE)
  • (Rarely needed) Tested as both an analyst and applicant user

As a designer reviewer, I have

Verified that the changes match the design intention

  • Checked that the design translated visually
  • Checked behavior. Comment any found issues or broken flows.
  • Checked different states (empty, one, some, error)
  • Checked for landmarks, page heading structure, and links

Validated user-facing changes as a designer

  • Checked keyboard navigability
  • screen reader (such as NVDA with Chrome or Voiceover with Safari):
    • Tested general usability
    • landmarks
    • page header structure
    • links
  • Checked for errors or warnings with an a11y browser tool (such as ANDI or WAVE)
  • Tested with multiple browsers (check off which ones were used)
    • Chrome
    • Microsoft Edge
    • FireFox
    • Safari
  • (Rarely needed) Tested as both an analyst and applicant user

References

Screenshots

@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 6, 2026

🥳 Successfully deployed to developer sandbox cw.

@lizpearl lizpearl self-assigned this Feb 23, 2026
@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

…ct values based on the same logic new registrants use
@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.



class Command(BaseCommand):
help = "Updates registry disclose settings for PublicContact records to whatever the website currently computes."
Copy link
Copy Markdown
Contributor

@CocoByte CocoByte Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: recommend updating this to reflect new functionality when finished

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 6, 2026

🥳 Successfully deployed to developer sandbox cw.

@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

Comment thread src/registrar/management/commands/update_public_contact_disclosure_settings.py Outdated
Copy link
Copy Markdown
Contributor

@CocoByte CocoByte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Got a few questions (tired brain) -- and one small change request

@github-project-automation github-project-automation Bot moved this to 👀 In review in .gov Product Board Apr 15, 2026
Co-authored-by: CuriousX <nicolle.leclair@gmail.com>
@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

@CocoByte CocoByte self-requested a review April 16, 2026 19:38
Copy link
Copy Markdown
Contributor

@lizpearl lizpearl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of overall comments/questions:

  • Is there a reason that the script includes contacts other than the registrant (like a scope change)? I think just dealing with registrant info would simplify the script.
  • I noticed the queryset uses public contacts as the primary table to pull from. Just curious why it was used instead of domains.
  • Since we're limiting this to registrants, we can prob just update if we're set to the default value

Comment thread src/registrar/management/commands/update_public_contact_disclosure_settings.py Outdated
@chaswick
Copy link
Copy Markdown
Contributor Author

chaswick commented Apr 21, 2026

A couple of overall comments/questions:

  • Is there a reason that the script includes contacts other than the registrant (like a scope change)? I think just dealing with registrant info would simplify the script.
    -- We modified the code in the previous work so that other contact types do not necessarily have the same logic as they did (like Security and Technical). It seemed to make sense.
  • I noticed the queryset uses public contacts as the primary table to pull from. Just curious why it was used instead of domains.
    -- The issue was written from the standpoint of updating public contact information, so that is the focus it was started from. Domains in this case is acting as categorization and filtering mechanism, so it wasn't the first part of the script developed.
  • Since we're limiting this to registrants, we can prob just update if we're set to the default value
    Updated to just work with registrant contact types

@github-actions
Copy link
Copy Markdown

🥳 Successfully deployed to developer sandbox cw.

@chaswick chaswick requested a review from lizpearl April 22, 2026 00:50
Copy link
Copy Markdown
Contributor

@CocoByte CocoByte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved - with one item to look at for logs (see comment) Functionally, script is working as expected.

Tested on -backup. Dry run info looks good. Might want to include more details for proposed contact values, but disclosure updates were easy to see.

Gotta admit it was a little painful to see that nice contact type argument go (per discussions we had today), but at least we know we can always reinstate it later if we want to run updates for other contacts. Thanks for being flexible on the script and the quick updates, @chaswick

updated_contact.city = new_values["city"]
updated_contact.sp = new_values["state_territory"]
updated_contact.pc = new_values["zipcode"]
logger.info("Proposed new contact values: %s", updated_contact)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just shows the contact id...did we want to show other values?

Copy link
Copy Markdown
Contributor

@lizpearl lizpearl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I tested this on my sandbox which has some outdated staging value. I realized that there won't be much value running the whole test on staging because it will essentially create many orphaned contacts. Probably best to do selected domains in staging instead

@chaswick chaswick merged commit b12e3c0 into main Apr 23, 2026
20 of 21 checks passed
@chaswick chaswick deleted the cw/3618-script-to-update-public-contact-org-city-state branch April 23, 2026 16:57
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in .gov Product Board Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Script to update Public Contact org, city and state values to actual registrant values

3 participants