aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2020-08-27 13:56:56 +0100
committerMatthew Lemon <matt@matthewlemon.com>2020-08-27 13:56:56 +0100
commitde0bbafec7d1aac5aaf9c672678c257b62f14d67 (patch)
tree2fa109f3e5f690af794b5a6cca072b2f56011929
parent75c34b747fc3f6cc776266200db4d1177ca7093e (diff)
essential service now on admin and further work to schema
-rw-r--r--ctrack/caf/admin.py14
-rw-r--r--ctrack/caf/migrations/0002_caf_systems.py18
-rw-r--r--ctrack/caf/models.py3
-rw-r--r--ctrack/core/utils.py21
-rw-r--r--ctrack/register/migrations/0001_initial.py4
-rw-r--r--ctrack/register/migrations/0002_engagementevent_user.py4
-rw-r--r--ctrack/users/migrations/0001_initial.py2
7 files changed, 53 insertions, 13 deletions
diff --git a/ctrack/caf/admin.py b/ctrack/caf/admin.py
index e633029..f1aa860 100644
--- a/ctrack/caf/admin.py
+++ b/ctrack/caf/admin.py
@@ -1,6 +1,17 @@
from django.contrib import admin
-from .models import CAF, FileStore, DocumentFile, Grading, ApplicableSystem
+from .models import (
+ CAF,
+ FileStore,
+ DocumentFile,
+ Grading,
+ ApplicableSystem,
+ EssentialService,
+)
+
+
+class EssentialServiceAdmin(admin.ModelAdmin):
+ model = EssentialService
class ApplicableSystemListAdmin(admin.ModelAdmin):
@@ -31,6 +42,7 @@ class CAFAdmin(admin.ModelAdmin):
admin.site.register(CAF, CAFAdmin)
+admin.site.register(EssentialService, EssentialServiceAdmin)
admin.site.register(FileStore)
admin.site.register(DocumentFile)
admin.site.register(Grading)
diff --git a/ctrack/caf/migrations/0002_caf_systems.py b/ctrack/caf/migrations/0002_caf_systems.py
new file mode 100644
index 0000000..9e0f76a
--- /dev/null
+++ b/ctrack/caf/migrations/0002_caf_systems.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.12 on 2020-08-27 12:44
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('caf', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='caf',
+ name='systems',
+ field=models.ManyToManyField(to='caf.ApplicableSystem'),
+ ),
+ ]
diff --git a/ctrack/caf/models.py b/ctrack/caf/models.py
index fc56c30..b77cfdb 100644
--- a/ctrack/caf/models.py
+++ b/ctrack/caf/models.py
@@ -89,7 +89,7 @@ class ApplicableSystem(models.Model):
return self.organisation.person_set.filter(primary_nis_contact=True)
def __str__(self):
- return f"{self.organisation.name} | {self.name}"
+ return self.name
objects = ApplicableSystemManager()
@@ -128,6 +128,7 @@ class CAF(models.Model):
triage_review_inspector = models.ForeignKey(
Person, on_delete=models.CASCADE, blank=True, null=True
)
+ systems = models.ManyToManyField(ApplicableSystem)
comments = models.TextField(max_length=1000)
class Meta:
diff --git a/ctrack/core/utils.py b/ctrack/core/utils.py
index c0f6cba..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,6 +52,17 @@ 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),
@@ -59,9 +70,7 @@ def _create_caf_app_service(c_descriptors, org, q_descriptors):
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))
+ caf.systems.add(as1, as2)
def populate_db(**kwargs):
@@ -218,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/register/migrations/0001_initial.py b/ctrack/register/migrations/0001_initial.py
index 4a878d7..30a69ba 100644
--- a/ctrack/register/migrations/0001_initial.py
+++ b/ctrack/register/migrations/0001_initial.py
@@ -1,4 +1,4 @@
-# Generated by Django 2.2.12 on 2020-08-27 09:40
+# Generated by Django 2.2.12 on 2020-08-27 12:44
from django.db import migrations, models
import django.db.models.deletion
@@ -10,7 +10,7 @@ class Migration(migrations.Migration):
dependencies = [
('organisations', '0001_initial'),
- ('caf', '0001_initial'),
+ ('caf', '0002_caf_systems'),
]
operations = [
diff --git a/ctrack/register/migrations/0002_engagementevent_user.py b/ctrack/register/migrations/0002_engagementevent_user.py
index 01de5b9..56866dc 100644
--- a/ctrack/register/migrations/0002_engagementevent_user.py
+++ b/ctrack/register/migrations/0002_engagementevent_user.py
@@ -1,4 +1,4 @@
-# Generated by Django 2.2.12 on 2020-08-27 09:40
+# Generated by Django 2.2.12 on 2020-08-27 12:44
import ctrack.register.models
from django.conf import settings
@@ -10,8 +10,8 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
- migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('register', '0001_initial'),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
diff --git a/ctrack/users/migrations/0001_initial.py b/ctrack/users/migrations/0001_initial.py
index bc74b13..df3cd12 100644
--- a/ctrack/users/migrations/0001_initial.py
+++ b/ctrack/users/migrations/0001_initial.py
@@ -1,4 +1,4 @@
-# Generated by Django 2.2.12 on 2020-08-27 09:40
+# Generated by Django 2.2.12 on 2020-08-27 12:44
import django.contrib.auth.models
import django.contrib.auth.validators