diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2020-03-04 21:05:24 +0000 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2020-03-04 21:05:24 +0000 |
commit | e20afcf33bac3d1aadeaf37358640513219c2b07 (patch) | |
tree | b4b0c87f062e8a7ac1d85cfa9a195441c1725c9c /ctrack | |
parent | 0943dde1fe36876d23a3abfca75c9719f9eafd33 (diff) |
added an all-in-one truncate and populate script and better population code
Diffstat (limited to 'ctrack')
-rw-r--r-- | ctrack/organisations/management/commands/populate_db.py | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/ctrack/organisations/management/commands/populate_db.py b/ctrack/organisations/management/commands/populate_db.py index e994b41..6f51a22 100644 --- a/ctrack/organisations/management/commands/populate_db.py +++ b/ctrack/organisations/management/commands/populate_db.py @@ -160,23 +160,12 @@ class Command(BaseCommand): # Every org gets on CAF for now for org in orgs: - # create a CAF for it - caf = CAFFactory.create( - quality_grading__descriptor=random.choice(q_descriptors), - confidence_grading__descriptor=random.choice(c_descriptors), - triage_review_date=None, - triage_review_inspector=None, - ) - # create an ApplicableSystem for it - app_s = ApplicableSystemFactory.create( - name=random.choice(fnames), - organisation=org, - caf=caf, - ) + # create a CAF and ApplicableService for it + self._create_caf_app_service(c_descriptors, org, q_descriptors) # CAF submissions - they create EngagementEvents # Get a random CAF - _caf = CAF.objects.get(pk=1) # we should have one by now + _caf = CAF.objects.get(pk=1) # we should have one by now ee3 = EngagementEventFactory.create( type=etf3, user=user, participants=[inspectors[1], p2], related_caf=_caf ) @@ -187,3 +176,18 @@ class Command(BaseCommand): f"Created {number} Person object[s]! Go forth and multiply." ) ) + + def _create_caf_app_service(self, c_descriptors, org, q_descriptors): + caf = CAFFactory.create( + quality_grading__descriptor=random.choice(q_descriptors), + confidence_grading__descriptor=random.choice(c_descriptors), + triage_review_date=None, + triage_review_inspector=None, + ) + # Each CAF can have up to three systems associated with it + for s in range(random.randint(1,3)): + ApplicableSystemFactory.create( + name=random.choice(fnames), + organisation=org, + caf=caf, + ) |