mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-28 23:33:32 +02:00
revising login simulation -- committing for sandbox testing
This commit is contained in:
parent
cb3cfe3a6d
commit
852f22a57a
3 changed files with 35 additions and 15 deletions
|
@ -84,6 +84,10 @@ FILE 1: **escrow_domain_contacts.daily.gov.GOV.txt** -> has the map of domain na
|
||||||
FILE 2: **escrow_contacts.daily.gov.GOV.txt** -> has the mapping of contact id to contact email address (which is what we care about for sending domain invitations)
|
FILE 2: **escrow_contacts.daily.gov.GOV.txt** -> has the mapping of contact id to contact email address (which is what we care about for sending domain invitations)
|
||||||
FILE 3: **escrow_domain_statuses.daily.gov.GOV.txt** -> has the map of domains and their statuses
|
FILE 3: **escrow_domain_statuses.daily.gov.GOV.txt** -> has the map of domains and their statuses
|
||||||
|
|
||||||
|
We need to run a few scripts to parse these files into our domain tables.
|
||||||
|
We can do this both locally and in a sandbox.
|
||||||
|
|
||||||
|
## OPTION 1: SANDBOX
|
||||||
## Load migration data onto a production or sandbox environment
|
## Load migration data onto a production or sandbox environment
|
||||||
**WARNING:** All files uploaded in this manner are temporary, i.e. they will be deleted when the app is restaged.
|
**WARNING:** All files uploaded in this manner are temporary, i.e. they will be deleted when the app is restaged.
|
||||||
Do not use this method to store data you want to keep around permanently.
|
Do not use this method to store data you want to keep around permanently.
|
||||||
|
@ -169,6 +173,7 @@ Run the following script to transfer the existing data on our .txt files to our
|
||||||
./manage.py load_transition_domain migrationdata/escrow_domain_contacts.daily.gov.GOV.txt migrationdata/escrow_contacts.daily.gov.GOV.txt migrationdata/escrow_domain_statuses.daily.gov.GOV.txt
|
./manage.py load_transition_domain migrationdata/escrow_domain_contacts.daily.gov.GOV.txt migrationdata/escrow_contacts.daily.gov.GOV.txt migrationdata/escrow_domain_statuses.daily.gov.GOV.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## OPTION 2: LOCAL
|
||||||
## Load migration data onto our local environments
|
## Load migration data onto our local environments
|
||||||
|
|
||||||
Transferring this data from these files into our domain tables happens in two steps;
|
Transferring this data from these files into our domain tables happens in two steps;
|
||||||
|
|
|
@ -12,7 +12,8 @@ from django.contrib.auth import get_user_model
|
||||||
from registrar.models import TransitionDomain
|
from registrar.models import TransitionDomain
|
||||||
from registrar.models import Domain
|
from registrar.models import Domain
|
||||||
from registrar.models import DomainInvitation
|
from registrar.models import DomainInvitation
|
||||||
from registrar.models.domain_information import DomainInformation
|
from registrar.models import DomainInformation
|
||||||
|
from registrar.models import User
|
||||||
|
|
||||||
from registrar.management.commands.utility.terminal_helper import TerminalColors
|
from registrar.management.commands.utility.terminal_helper import TerminalColors
|
||||||
from registrar.management.commands.utility.terminal_helper import TerminalHelper
|
from registrar.management.commands.utility.terminal_helper import TerminalHelper
|
||||||
|
@ -337,19 +338,33 @@ class Command(BaseCommand):
|
||||||
==================
|
==================
|
||||||
{TerminalColors.ENDC}
|
{TerminalColors.ENDC}
|
||||||
""")
|
""")
|
||||||
for invite in DomainInvitation.objects.all():
|
# for invite in DomainInvitation.objects.all():
|
||||||
#DEBUG:
|
# #DEBUG:
|
||||||
TerminalHelper.print_debug(debug_on,f"""{TerminalColors.OKCYAN}Processing invite: {invite}{TerminalColors.ENDC}""")
|
# TerminalHelper.print_conditional(debug_on,f"""{TerminalColors.OKCYAN}Processing invite: {invite}{TerminalColors.ENDC}""")
|
||||||
# get a user with this email address
|
# # get a user with this email address
|
||||||
User = get_user_model()
|
# user_exists = User.objects.filter(email=invite.email).exists()
|
||||||
try:
|
# user, _ = User.objects.get_or_create(email=invite.email)
|
||||||
user = User.objects.get(email=invite.email)
|
# #DEBUG:
|
||||||
#DEBUG:
|
# TerminalHelper.print_conditional(user_exists,f"""{TerminalColors.OKCYAN}No user found (creating temporary user object){TerminalColors.ENDC}""")
|
||||||
TerminalHelper.print_debug(debug_on,f"""{TerminalColors.OKCYAN}Logging in user: {user}{TerminalColors.ENDC}""")
|
# TerminalHelper.print_conditional(debug_on,f"""{TerminalColors.OKCYAN}Logging in user: {user}{TerminalColors.ENDC}""")
|
||||||
Client.force_login(user)
|
# user.first_login()
|
||||||
except User.DoesNotExist:
|
# if not user_exists:
|
||||||
#TODO: how should we handle this?
|
# logger.warn(f"""{TerminalColors.YELLOW}(Deleting temporary user object){TerminalColors.ENDC}""")
|
||||||
logger.warn(f"""{TerminalColors.FAIL}No user found {invite.email}{TerminalColors.ENDC}""")
|
# user.delete()
|
||||||
|
|
||||||
|
# for invite in DomainInvitation.objects.all():
|
||||||
|
# #DEBUG:
|
||||||
|
# TerminalHelper.print_debug(debug_on,f"""{TerminalColors.OKCYAN}Processing invite: {invite}{TerminalColors.ENDC}""")
|
||||||
|
# # get a user with this email address
|
||||||
|
# User = get_user_model()
|
||||||
|
# try:
|
||||||
|
# user = User.objects.get(email=invite.email)
|
||||||
|
# #DEBUG:
|
||||||
|
# TerminalHelper.print_debug(debug_on,f"""{TerminalColors.OKCYAN}Logging in user: {user}{TerminalColors.ENDC}""")
|
||||||
|
# Client.force_login(user)
|
||||||
|
# except User.DoesNotExist:
|
||||||
|
# #TODO: how should we handle this?
|
||||||
|
# logger.warn(f"""{TerminalColors.FAIL}No user found {invite.email}{TerminalColors.ENDC}""")
|
||||||
|
|
||||||
def handle(
|
def handle(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -49,7 +49,7 @@ class TerminalHelper:
|
||||||
else:
|
else:
|
||||||
logger.info("Please respond with 'yes' or 'no' " "(or 'y' or 'n').\n")
|
logger.info("Please respond with 'yes' or 'no' " "(or 'y' or 'n').\n")
|
||||||
|
|
||||||
def print_debug(print_condition: bool, print_statement: str):
|
def print_conditional(print_condition: bool, print_statement: str):
|
||||||
"""This function reduces complexity of debug statements
|
"""This function reduces complexity of debug statements
|
||||||
in other functions.
|
in other functions.
|
||||||
It uses the logger to write the given print_statement to the
|
It uses the logger to write the given print_statement to the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue