aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ctrack/caf/models.py4
-rw-r--r--ctrack/caf/tests/factories.py2
-rw-r--r--ctrack/organisations/management/commands/populate_db.py33
-rw-r--r--utility/truncate_script.sql1
4 files changed, 25 insertions, 15 deletions
diff --git a/ctrack/caf/models.py b/ctrack/caf/models.py
index b488962..c290ee3 100644
--- a/ctrack/caf/models.py
+++ b/ctrack/caf/models.py
@@ -74,4 +74,6 @@ class CAF(models.Model):
verbose_name = "CAF"
def __str__(self):
- return f"CAF | {self.owner}"
+ # Get the organisation and applicable system
+ org = ApplicableSystem.objects.filter(caf=self).first()
+ return f"CAF | {org.name}"
diff --git a/ctrack/caf/tests/factories.py b/ctrack/caf/tests/factories.py
index f2275a4..bc2431e 100644
--- a/ctrack/caf/tests/factories.py
+++ b/ctrack/caf/tests/factories.py
@@ -21,7 +21,7 @@ class CAFFactory(factory.DjangoModelFactory):
model = CAF
-class EssentialServiceFactory(factory.DjangoModelFactory):
+class ApplicableSystemFactory(factory.DjangoModelFactory):
"""Factory for Essential Services."""
name = Faker("text", max_nb_chars=100, ext_word_list=None)
diff --git a/ctrack/organisations/management/commands/populate_db.py b/ctrack/organisations/management/commands/populate_db.py
index 2800e85..217e43a 100644
--- a/ctrack/organisations/management/commands/populate_db.py
+++ b/ctrack/organisations/management/commands/populate_db.py
@@ -4,13 +4,14 @@ from random import randint, choice
from django.core.management import BaseCommand
from django.core.management import CommandParser
+from ctrack.caf.models import CAF
from ctrack.caf.tests.factories import (
GradingFactory,
FileStoreFactory,
CAFFactory,
- EssentialServiceFactory,
+ ApplicableSystemFactory,
)
-from ctrack.organisations.models import AddressType
+from ctrack.organisations.models import AddressType, Organisation
from ctrack.organisations.models import Mode
from ctrack.organisations.models import Submode
from ctrack.organisations.tests.factories import AddressFactory
@@ -157,29 +158,35 @@ class Command(BaseCommand):
# File store
fs = FileStoreFactory.create(physical_location_organisation=orgs[1])
- # Some CAF objects
- cafs = [
+ # Every org gets on CAF for now
+ for _ in orgs:
CAFFactory.create(
quality_grading__descriptor=random.choice(q_descriptors),
confidence_grading__descriptor=random.choice(c_descriptors),
triage_review_date=None,
triage_review_inspector=None,
)
- for _ in range(35)
- ]
- es = [
- EssentialServiceFactory.create(
+ 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=random.choice(orgs),
- caf=random.choice(cafs),
+ organisation=org,
+ caf=caf,
)
- for _ in range(35)
- ]
# CAF submissions - they create EngagementEvents
+ # Get a random CAF
+ _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=cafs[1]
+ type=etf3, user=user, participants=[inspectors[1], p2], related_caf=_caf
)
# TODO - adapt this so that it records more than just Persons created
diff --git a/utility/truncate_script.sql b/utility/truncate_script.sql
index 39dd8b4..2f72c9c 100644
--- a/utility/truncate_script.sql
+++ b/utility/truncate_script.sql
@@ -10,5 +10,6 @@ TRUNCATE TABLE register_engagementtype RESTART IDENTITY CASCADE;
TRUNCATE TABLE register_engagementevent RESTART IDENTITY CASCADE;
TRUNCATE TABLE caf_grading RESTART IDENTITY CASCADE;
TRUNCATE TABLE caf_caf RESTART IDENTITY CASCADE;
+TRUNCATE TABLE caf_documentfile RESTART IDENTITY CASCADE;
TRUNCATE TABLE caf_applicablesystem RESTART IDENTITY CASCADE;
DELETE FROM users_user WHERE username != 'mrlemon';