aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/core/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'ctrack/core/utils.py')
-rw-r--r--ctrack/core/utils.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/ctrack/core/utils.py b/ctrack/core/utils.py
index 0612c52..af01549 100644
--- a/ctrack/core/utils.py
+++ b/ctrack/core/utils.py
@@ -15,7 +15,7 @@ from ctrack.assessments.models import (
CAFObjective,
CAFPrinciple,
)
-from ctrack.caf.models import CAF
+from ctrack.caf.models import CAF, EssentialService
from ctrack.caf.tests.factories import (
ApplicableSystemFactory,
CAFFactory,
@@ -52,17 +52,25 @@ fnames = [
def _create_caf_app_service(c_descriptors, org, q_descriptors):
+ # Get the essential services and systems belonging to the org
+
+ es = EssentialService.objects.create(
+ name="".join(["Essential Service for ", org.name]),
+ description="Random description",
+ organisation=org,
+ )
+ as1 = ApplicableSystemFactory.create(name=random.choice(fnames))
+ as2 = ApplicableSystemFactory.create(name=random.choice(fnames))
+ es.systems.add(as1, as2)
+
caf = CAFFactory.create(
quality_grading__descriptor=random.choice(q_descriptors),
confidence_grading__descriptor=random.choice(c_descriptors),
+ organisation=org,
triage_review_date=None,
triage_review_inspector=None,
)
- # Each CAF can have up to three systems associated with it
- for _ in range(random.randint(1, 3)):
- ApplicableSystemFactory.create(
- name=random.choice(fnames), organisation=org, caf=caf,
- )
+ caf.systems.add(as1, as2)
def populate_db(**kwargs):
@@ -219,9 +227,9 @@ def populate_db(**kwargs):
# File store
FileStoreFactory.create(physical_location_organisation=orgs[1])
- # Every org gets on CAF for now
+ # Every org gets on CAF and Essential Service for now
for org in orgs:
- # create a CAF and ApplicableService for it
+ # create a CAF
_create_caf_app_service(c_descriptors, org, q_descriptors)
# CAF submissions - they create EngagementEvents