mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-16 17:47:02 +02:00
Fixtures for approved domains
This commit is contained in:
parent
ab1eb0ead1
commit
96b95bae8a
2 changed files with 25 additions and 1 deletions
|
@ -107,6 +107,10 @@ class DomainApplicationFixture:
|
||||||
"status": "investigating",
|
"status": "investigating",
|
||||||
"organization_name": "Example - In Investigation",
|
"organization_name": "Example - In Investigation",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"status": "investigating",
|
||||||
|
"organization_name": "Example - Approved",
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -249,3 +253,22 @@ class DomainApplicationFixture:
|
||||||
cls._set_many_to_many_relations(da, app)
|
cls._set_many_to_many_relations(da, app)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
|
|
||||||
|
class DomainFixture(DomainApplicationFixture):
|
||||||
|
|
||||||
|
"""Create one domain and permissions on it for each user."""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load(cls):
|
||||||
|
try:
|
||||||
|
users = list(User.objects.all()) # force evaluation to catch db errors
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(e)
|
||||||
|
return
|
||||||
|
|
||||||
|
for user in users:
|
||||||
|
# approve one of each users investigating status domains
|
||||||
|
application = DomainApplication.objects.filter(creator=user, status=DomainApplication.INVESTIGATING).last()
|
||||||
|
logger.debug(f"Approving {application} for {user}")
|
||||||
|
application.approve()
|
||||||
|
application.save()
|
||||||
|
|
|
@ -3,7 +3,7 @@ import logging
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from auditlog.context import disable_auditlog # type: ignore
|
from auditlog.context import disable_auditlog # type: ignore
|
||||||
|
|
||||||
from registrar.fixtures import UserFixture, DomainApplicationFixture
|
from registrar.fixtures import UserFixture, DomainApplicationFixture, DomainFixture
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -15,4 +15,5 @@ class Command(BaseCommand):
|
||||||
with disable_auditlog():
|
with disable_auditlog():
|
||||||
UserFixture.load()
|
UserFixture.load()
|
||||||
DomainApplicationFixture.load()
|
DomainApplicationFixture.load()
|
||||||
|
DomainFixture.load()
|
||||||
logger.info("All fixtures loaded.")
|
logger.info("All fixtures loaded.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue