mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-15 05:54:11 +02:00
Merge branch 'main' into backup/2594-design-review
This commit is contained in:
commit
af3acbc773
5 changed files with 85 additions and 25 deletions
22
.github/workflows/clone-staging.yaml
vendored
22
.github/workflows/clone-staging.yaml
vendored
|
@ -1,11 +1,9 @@
|
||||||
name: Clone Staging Database
|
name: Clone Staging Database
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# these will be uncommented after testing
|
schedule:
|
||||||
# ----
|
# Run daily at 2:00 PM EST
|
||||||
# schedule:
|
- cron: '0 * * * *'
|
||||||
# # Run daily at 2:00 PM EST
|
|
||||||
# - cron: '0 * * * *'
|
|
||||||
# Allow manual triggering
|
# Allow manual triggering
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
@ -16,7 +14,7 @@ env:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
clone-database:
|
clone-database:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
env:
|
env:
|
||||||
CF_USERNAME: ${{ secrets.CF_MS_USERNAME }}
|
CF_USERNAME: ${{ secrets.CF_MS_USERNAME }}
|
||||||
CF_PASSWORD: ${{ secrets.CF_MS_PASSWORD }}
|
CF_PASSWORD: ${{ secrets.CF_MS_PASSWORD }}
|
||||||
|
@ -28,7 +26,8 @@ jobs:
|
||||||
echo "deb [signed-by=/usr/share/keyrings/cli.cloudfoundry.org.gpg] https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
|
echo "deb [signed-by=/usr/share/keyrings/cli.cloudfoundry.org.gpg] https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
|
||||||
|
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install cf8-cli postgresql-client-common
|
sudo apt-get install cf8-cli
|
||||||
|
|
||||||
# install cg-manage-rds tool
|
# install cg-manage-rds tool
|
||||||
pip install git+https://github.com/cloud-gov/cg-manage-rds.git
|
pip install git+https://github.com/cloud-gov/cg-manage-rds.git
|
||||||
|
|
||||||
|
@ -41,7 +40,8 @@ jobs:
|
||||||
cf share-service getgov-$DESTINATION_ENVIRONMENT-database -s $SOURCE_ENVIRONMENT
|
cf share-service getgov-$DESTINATION_ENVIRONMENT-database -s $SOURCE_ENVIRONMENT
|
||||||
|
|
||||||
# clone from source to destination
|
# clone from source to destination
|
||||||
cg-manage-rds clone getgov-$DESTINATION_ENVIRONMENT-database getgov-$SOURCE_ENVIRONMENT-database
|
cf target -s $SOURCE_ENVIRONMENT
|
||||||
|
cg-manage-rds clone --roptions "--clean --if-exists" getgov-$SOURCE_ENVIRONMENT-database getgov-$DESTINATION_ENVIRONMENT-database
|
||||||
# unshare the service
|
- name: Cleanup
|
||||||
cf unshare-service getgov-$DESTINATION_ENVIRONMENT-database -s $SOURCE_ENVIRONMENT
|
if: always()
|
||||||
|
run: cf unshare-service getgov-$DESTINATION_ENVIRONMENT-database -s $SOURCE_ENVIRONMENT -f
|
||||||
|
|
|
@ -1640,6 +1640,70 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
def lookups(self, request, model_admin):
|
def lookups(self, request, model_admin):
|
||||||
return DomainRequest.DomainRequestStatus.choices
|
return DomainRequest.DomainRequestStatus.choices
|
||||||
|
|
||||||
|
class GenericOrgFilter(admin.SimpleListFilter):
|
||||||
|
"""Custom Generic Organization filter that accomodates portfolio feature.
|
||||||
|
If we have a portfolio, use the portfolio's organization. If not, use the
|
||||||
|
organization in the Domain Request object."""
|
||||||
|
|
||||||
|
title = "generic organization"
|
||||||
|
parameter_name = "converted_generic_orgs"
|
||||||
|
|
||||||
|
def lookups(self, request, model_admin):
|
||||||
|
converted_generic_orgs = set()
|
||||||
|
|
||||||
|
for domain_request in DomainRequest.objects.all():
|
||||||
|
converted_generic_org = domain_request.converted_generic_org_type
|
||||||
|
if converted_generic_org:
|
||||||
|
converted_generic_orgs.add(converted_generic_org)
|
||||||
|
|
||||||
|
return sorted((org, org) for org in converted_generic_orgs)
|
||||||
|
|
||||||
|
# Filter queryset
|
||||||
|
def queryset(self, request, queryset):
|
||||||
|
if self.value(): # Check if a generic org is selected in the filter
|
||||||
|
return queryset.filter(
|
||||||
|
# Filter based on the generic org value returned by converted_generic_org_type
|
||||||
|
id__in=[
|
||||||
|
domain_request.id
|
||||||
|
for domain_request in queryset
|
||||||
|
if domain_request.converted_generic_org_type
|
||||||
|
and domain_request.converted_generic_org_type == self.value()
|
||||||
|
]
|
||||||
|
)
|
||||||
|
return queryset
|
||||||
|
|
||||||
|
class FederalTypeFilter(admin.SimpleListFilter):
|
||||||
|
"""Custom Federal Type filter that accomodates portfolio feature.
|
||||||
|
If we have a portfolio, use the portfolio's federal type. If not, use the
|
||||||
|
organization in the Domain Request object."""
|
||||||
|
|
||||||
|
title = "federal Type"
|
||||||
|
parameter_name = "converted_federal_types"
|
||||||
|
|
||||||
|
def lookups(self, request, model_admin):
|
||||||
|
converted_federal_types = set()
|
||||||
|
|
||||||
|
for domain_request in DomainRequest.objects.all():
|
||||||
|
converted_federal_type = domain_request.converted_federal_type
|
||||||
|
if converted_federal_type:
|
||||||
|
converted_federal_types.add(converted_federal_type)
|
||||||
|
|
||||||
|
return sorted((type, type) for type in converted_federal_types)
|
||||||
|
|
||||||
|
# Filter queryset
|
||||||
|
def queryset(self, request, queryset):
|
||||||
|
if self.value(): # Check if federal Type is selected in the filter
|
||||||
|
return queryset.filter(
|
||||||
|
# Filter based on the federal type returned by converted_federal_type
|
||||||
|
id__in=[
|
||||||
|
domain_request.id
|
||||||
|
for domain_request in queryset
|
||||||
|
if domain_request.converted_federal_type
|
||||||
|
and domain_request.converted_federal_type == self.value()
|
||||||
|
]
|
||||||
|
)
|
||||||
|
return queryset
|
||||||
|
|
||||||
class InvestigatorFilter(admin.SimpleListFilter):
|
class InvestigatorFilter(admin.SimpleListFilter):
|
||||||
"""Custom investigator filter that only displays users with the manager role"""
|
"""Custom investigator filter that only displays users with the manager role"""
|
||||||
|
|
||||||
|
@ -1762,8 +1826,8 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
# Filters
|
# Filters
|
||||||
list_filter = (
|
list_filter = (
|
||||||
StatusListFilter,
|
StatusListFilter,
|
||||||
"generic_org_type",
|
GenericOrgFilter,
|
||||||
"federal_type",
|
FederalTypeFilter,
|
||||||
ElectionOfficeFilter,
|
ElectionOfficeFilter,
|
||||||
"rejection_reason",
|
"rejection_reason",
|
||||||
InvestigatorFilter,
|
InvestigatorFilter,
|
||||||
|
@ -1876,7 +1940,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
|
|
||||||
# Read only that we'll leverage for CISA Analysts
|
# Read only that we'll leverage for CISA Analysts
|
||||||
analyst_readonly_fields = [
|
analyst_readonly_fields = [
|
||||||
"converted_federal_agency",
|
"federal_agency",
|
||||||
"creator",
|
"creator",
|
||||||
"about_your_organization",
|
"about_your_organization",
|
||||||
"requested_domain",
|
"requested_domain",
|
||||||
|
|
|
@ -576,7 +576,7 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
response = self.client.get("/admin/registrar/domainrequest/?generic_org_type__exact=federal")
|
response = self.client.get("/admin/registrar/domainrequest/?generic_org_type__exact=federal")
|
||||||
# There are 2 template references to Federal (4) and two in the results data
|
# There are 2 template references to Federal (4) and two in the results data
|
||||||
# of the request
|
# of the request
|
||||||
self.assertContains(response, "Federal", count=52)
|
self.assertContains(response, "Federal", count=51)
|
||||||
# This may be a bit more robust
|
# This may be a bit more robust
|
||||||
self.assertContains(response, '<td class="field-converted_generic_org_type">federal</td>', count=1)
|
self.assertContains(response, '<td class="field-converted_generic_org_type">federal</td>', count=1)
|
||||||
# Now let's make sure the long description does not exist
|
# Now let's make sure the long description does not exist
|
||||||
|
@ -1696,7 +1696,7 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
"alternative_domains",
|
"alternative_domains",
|
||||||
"is_election_board",
|
"is_election_board",
|
||||||
"status_history",
|
"status_history",
|
||||||
"converted_federal_agency",
|
"federal_agency",
|
||||||
"creator",
|
"creator",
|
||||||
"about_your_organization",
|
"about_your_organization",
|
||||||
"requested_domain",
|
"requested_domain",
|
||||||
|
@ -1935,8 +1935,8 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
readonly_fields = self.admin.get_list_filter(request)
|
readonly_fields = self.admin.get_list_filter(request)
|
||||||
expected_fields = (
|
expected_fields = (
|
||||||
DomainRequestAdmin.StatusListFilter,
|
DomainRequestAdmin.StatusListFilter,
|
||||||
"generic_org_type",
|
DomainRequestAdmin.GenericOrgFilter,
|
||||||
"federal_type",
|
DomainRequestAdmin.FederalTypeFilter,
|
||||||
DomainRequestAdmin.ElectionOfficeFilter,
|
DomainRequestAdmin.ElectionOfficeFilter,
|
||||||
"rejection_reason",
|
"rejection_reason",
|
||||||
DomainRequestAdmin.InvestigatorFilter,
|
DomainRequestAdmin.InvestigatorFilter,
|
||||||
|
|
|
@ -682,7 +682,6 @@ class ExportDataTest(MockDbForIndividualTests, MockEppLib):
|
||||||
def test_domain_request_growth(self):
|
def test_domain_request_growth(self):
|
||||||
"""Shows submitted requests within a date range, sorted"""
|
"""Shows submitted requests within a date range, sorted"""
|
||||||
# Remove "Submitted at" because we can't guess this immutable, dynamically generated test data
|
# Remove "Submitted at" because we can't guess this immutable, dynamically generated test data
|
||||||
print("we are in here")
|
|
||||||
columns = [
|
columns = [
|
||||||
"Domain request",
|
"Domain request",
|
||||||
"Domain type",
|
"Domain type",
|
||||||
|
@ -693,7 +692,6 @@ class ExportDataTest(MockDbForIndividualTests, MockEppLib):
|
||||||
# Create a CSV file in memory
|
# Create a CSV file in memory
|
||||||
csv_file = StringIO()
|
csv_file = StringIO()
|
||||||
# Call the export functions
|
# Call the export functions
|
||||||
print("something")
|
|
||||||
DomainRequestGrowth.export_data_to_csv(
|
DomainRequestGrowth.export_data_to_csv(
|
||||||
csv_file,
|
csv_file,
|
||||||
start_date=self.start_date.strftime("%Y-%m-%d"),
|
start_date=self.start_date.strftime("%Y-%m-%d"),
|
||||||
|
@ -701,11 +699,9 @@ class ExportDataTest(MockDbForIndividualTests, MockEppLib):
|
||||||
)
|
)
|
||||||
# Reset the CSV file's position to the beginning
|
# Reset the CSV file's position to the beginning
|
||||||
csv_file.seek(0)
|
csv_file.seek(0)
|
||||||
print("uuuuu")
|
|
||||||
print(csv_file)
|
|
||||||
# Read the content into a variable
|
# Read the content into a variable
|
||||||
csv_content = csv_file.read()
|
csv_content = csv_file.read()
|
||||||
print(csv_content)
|
|
||||||
expected_content = (
|
expected_content = (
|
||||||
"Domain request,Domain type,Federal type\n"
|
"Domain request,Domain type,Federal type\n"
|
||||||
"city3.gov,Federal,Executive\n"
|
"city3.gov,Federal,Executive\n"
|
||||||
|
|
|
@ -1269,7 +1269,7 @@ class DomainRequestExport(BaseExport):
|
||||||
human_readable_federal_type = BranchChoices.get_branch_label(federal_type) if federal_type else None
|
human_readable_federal_type = BranchChoices.get_branch_label(federal_type) if federal_type else None
|
||||||
|
|
||||||
# Handle the org_type field
|
# Handle the org_type field
|
||||||
org_type = model.get("generic_org_type")
|
org_type = model.get("generic_org_type") or model.get("organization_type")
|
||||||
human_readable_org_type = DomainRequest.OrganizationChoices.get_org_label(org_type) if org_type else None
|
human_readable_org_type = DomainRequest.OrganizationChoices.get_org_label(org_type) if org_type else None
|
||||||
|
|
||||||
# Handle the status field. Defaults to the wrong format.
|
# Handle the status field. Defaults to the wrong format.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue