mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-13 04:59:59 +02:00
Add more documentation
This commit is contained in:
parent
d25d8f5d1f
commit
26ddf317d5
2 changed files with 33 additions and 4 deletions
|
@ -697,3 +697,30 @@ Example: `cf ssh getgov-za`
|
||||||
| | Parameter | Description |
|
| | Parameter | Description |
|
||||||
|:-:|:-------------------------- |:----------------------------------------------------------------------------|
|
|:-:|:-------------------------- |:----------------------------------------------------------------------------|
|
||||||
| 1 | **debug** | Increases logging detail. Defaults to False. |
|
| 1 | **debug** | Increases logging detail. Defaults to False. |
|
||||||
|
|
||||||
|
## Transfer federal agency script
|
||||||
|
The transfer federal agency script adds the "federal_type" field on each associated DomainRequest, and uses that to populate the "federal_type" field on each FederalAgency.
|
||||||
|
|
||||||
|
**Important:** When running this script, note that data generated by our fixtures will be inaccurate (since we assign random data to them). Use real data on this script.
|
||||||
|
Do note that there is a check on record uniqueness. If two or more records do NOT have the same value for federal_type for any given federal agency, then the record is skipped. This protects against fixtures data when loaded with real data.
|
||||||
|
|
||||||
|
### Running on sandboxes
|
||||||
|
|
||||||
|
#### Step 1: Login to CloudFoundry
|
||||||
|
```cf login -a api.fr.cloud.gov --sso```
|
||||||
|
|
||||||
|
#### Step 2: SSH into your environment
|
||||||
|
```cf ssh getgov-{space}```
|
||||||
|
|
||||||
|
Example: `cf ssh getgov-za`
|
||||||
|
|
||||||
|
#### Step 3: Create a shell instance
|
||||||
|
```/tmp/lifecycle/shell```
|
||||||
|
|
||||||
|
#### Step 4: Running the script
|
||||||
|
```./manage.py transfer_federal_agency_type```
|
||||||
|
|
||||||
|
### Running locally
|
||||||
|
|
||||||
|
#### Step 1: Running the script
|
||||||
|
```docker-compose exec app ./manage.py transfer_federal_agency_type```
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Command(BaseCommand, PopulateScriptTemplate):
|
||||||
def handle(self, **kwargs):
|
def handle(self, **kwargs):
|
||||||
"""Loops through each valid User object and updates its verification_type value"""
|
"""Loops through each valid User object and updates its verification_type value"""
|
||||||
|
|
||||||
# Get all existing domain requests
|
# Get all existing domain requests. Select_related allows us to skip doing db queries.
|
||||||
self.all_domain_requests = DomainRequest.objects.select_related("federal_agency").distinct()
|
self.all_domain_requests = DomainRequest.objects.select_related("federal_agency").distinct()
|
||||||
self.mass_update_records(
|
self.mass_update_records(
|
||||||
FederalAgency, filter_conditions={"agency__isnull": False}, fields_to_update=["federal_type"]
|
FederalAgency, filter_conditions={"agency__isnull": False}, fields_to_update=["federal_type"]
|
||||||
|
@ -31,6 +31,8 @@ class Command(BaseCommand, PopulateScriptTemplate):
|
||||||
|
|
||||||
def should_skip_record(self, record) -> bool: # noqa
|
def should_skip_record(self, record) -> bool: # noqa
|
||||||
"""Defines the conditions in which we should skip updating a record."""
|
"""Defines the conditions in which we should skip updating a record."""
|
||||||
request = self.all_domain_requests.filter(federal_agency__agency=record.agency).first()
|
requests = self.all_domain_requests.filter(federal_agency__agency=record.agency, federal_type__isnull=False)
|
||||||
return not request or not request.federal_agency
|
# Check if all federal_type values are the same. Skip the record otherwise.
|
||||||
|
distinct_federal_types = requests.values('federal_type').distinct()
|
||||||
|
return distinct_federal_types.count() != 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue