diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2020-09-02 12:04:19 +0100 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2020-09-02 12:04:19 +0100 |
commit | edd91cb77191b386af95dfaca0b2706c7ee143b9 (patch) | |
tree | b94edf8e069911d0aea4e1acfc23a72a180cb2cf /ctrack/core | |
parent | 15c89a78c097dc00ad7b8ca3314581ed3b058187 (diff) | |
parent | c406d3da83d20d65c2fc4da7d5d4d5db0f6ad115 (diff) |
Merge branch 'db_rewrite' into master
Diffstat (limited to 'ctrack/core')
-rw-r--r-- | ctrack/core/utils.py | 24 | ||||
-rw-r--r-- | ctrack/core/views.py | 2 |
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( |