aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/caf
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2020-08-13 15:46:10 +0100
committerMatthew Lemon <matt@matthewlemon.com>2020-08-13 15:46:10 +0100
commitfa9033e81943fdd577ebc135ea9c4cf98404677f (patch)
tree9405743b345abaee9c482dd615af86e3b8216603 /ctrack/caf
parent5a955f9796c199338eb3182f1918c4708593a1be (diff)
added a new field to the applicablesystem model
Diffstat (limited to 'ctrack/caf')
-rw-r--r--ctrack/caf/forms.py11
-rw-r--r--ctrack/caf/migrations/0005_applicablesystem_oes_categorisation.py18
-rw-r--r--ctrack/caf/migrations/0006_auto_20200813_1125.py22
-rw-r--r--ctrack/caf/models.py14
-rw-r--r--ctrack/caf/tests/factories.py1
5 files changed, 66 insertions, 0 deletions
diff --git a/ctrack/caf/forms.py b/ctrack/caf/forms.py
index 9847f01..4a03213 100644
--- a/ctrack/caf/forms.py
+++ b/ctrack/caf/forms.py
@@ -22,6 +22,10 @@ class ApplicableSystemCreateFromCafForm(forms.Form):
function = forms.CharField(widget=forms.Textarea)
organisation = forms.ModelChoiceField(queryset=Organisation.objects.all())
caf = forms.ModelChoiceField(queryset=CAF.objects.all())
+ dft_categorisation = forms.ChoiceField(
+ choices=ApplicableSystem.SYSTEM_CATEGORISATION,
+ help_text="Refer to documentation for description of these criteria",
+ )
def __init__(self, *args, **kwargs):
# We must pop the kwargs before we pass to super()
@@ -38,6 +42,7 @@ class ApplicableSystemCreateFromCafForm(forms.Form):
"",
Field("name", css_class="form-control-lg"),
"function",
+ Field("dft_categorisation", css_class="form-control-lg",),
Hidden("caf", caf_id),
Hidden("organisation", org_id),
),
@@ -52,6 +57,12 @@ class ApplicableSystemCreateFromCafForm(forms.Form):
),
)
+ class Meta:
+ model = ApplicableSystem
+ labels = {
+ "dft_categorisation": "DFT CATEGORISATION",
+ }
+
class ApplicableSystemCreateFromOrgForm(forms.Form):
name = forms.CharField(max_length=255)
diff --git a/ctrack/caf/migrations/0005_applicablesystem_oes_categorisation.py b/ctrack/caf/migrations/0005_applicablesystem_oes_categorisation.py
new file mode 100644
index 0000000..dc8c928
--- /dev/null
+++ b/ctrack/caf/migrations/0005_applicablesystem_oes_categorisation.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.12 on 2020-08-13 11:17
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('caf', '0004_auto_20200813_0953'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='applicablesystem',
+ name='oes_categorisation',
+ field=models.CharField(choices=[('CR', 'Critical'), ('IM', 'Important')], default='CR', max_length=2),
+ ),
+ ]
diff --git a/ctrack/caf/migrations/0006_auto_20200813_1125.py b/ctrack/caf/migrations/0006_auto_20200813_1125.py
new file mode 100644
index 0000000..1e97dff
--- /dev/null
+++ b/ctrack/caf/migrations/0006_auto_20200813_1125.py
@@ -0,0 +1,22 @@
+# Generated by Django 2.2.12 on 2020-08-13 11:25
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('caf', '0005_applicablesystem_oes_categorisation'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='applicablesystem',
+ name='oes_categorisation',
+ ),
+ migrations.AddField(
+ model_name='applicablesystem',
+ name='dft_categorisation',
+ field=models.CharField(choices=[('CR', 'Critical'), ('IM', 'Important')], default='CR', help_text='Refer to documentation for description of these criteria', max_length=2, verbose_name='DfT Categorisation'),
+ ),
+ ]
diff --git a/ctrack/caf/models.py b/ctrack/caf/models.py
index bfc4765..444ab6b 100644
--- a/ctrack/caf/models.py
+++ b/ctrack/caf/models.py
@@ -45,6 +45,13 @@ class DocumentFile(models.Model):
class ApplicableSystem(models.Model):
+ CRITICAL = "CR"
+ IMPORTANT = "IM"
+ SYSTEM_CATEGORISATION = (
+ (CRITICAL, "Critical"),
+ (IMPORTANT, "Important"),
+ )
+
def get_sentinel_org():
"""
We need this so that we can ensure models.SET() is applied with a callable
@@ -71,6 +78,13 @@ class ApplicableSystem(models.Model):
null=True,
related_name="applicable_systems",
)
+ dft_categorisation = models.CharField(
+ max_length=2,
+ choices=SYSTEM_CATEGORISATION,
+ default=CRITICAL,
+ verbose_name="DfT Categorisation",
+ help_text="Refer to documentation for description of these criteria",
+ )
class Meta:
verbose_name = "NIS System"
diff --git a/ctrack/caf/tests/factories.py b/ctrack/caf/tests/factories.py
index 4c2d5b8..3c62307 100644
--- a/ctrack/caf/tests/factories.py
+++ b/ctrack/caf/tests/factories.py
@@ -31,6 +31,7 @@ class ApplicableSystemFactory(factory.DjangoModelFactory):
)
organisation = factory.SubFactory(OrganisationFactory)
caf = factory.SubFactory("ctrack.caf.tests.factories.CAFFactory")
+ dft_categorisation = "CR"
class Meta:
model = ApplicableSystem