aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/core
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ctrack/core/utils.py24
-rw-r--r--ctrack/core/views.py2
2 files changed, 17 insertions, 9 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
diff --git a/ctrack/core/views.py b/ctrack/core/views.py
index 5f5627c..d7efe34 100644
--- a/ctrack/core/views.py
+++ b/ctrack/core/views.py
@@ -12,7 +12,7 @@ def home_page(request):
name=request.user.stakeholder.person.get_organisation_name()
)
irs = IncidentReport.objects.filter(organisation__name=org)
- systems = org.applicablesystem_set.all()
+ systems = org.applicable_systems()
peoples = org.person_set.all()
engagement_events = EngagementEvent.objects.filter(participants__in=peoples)
return render(