aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.rst5
-rw-r--r--ctrack/caf/forms.py37
-rw-r--r--ctrack/caf/migrations/0004_auto_20200813_0953.py31
-rw-r--r--ctrack/caf/models.py10
-rw-r--r--ctrack/caf/templates/caf/applicablesystem_detail.html4
-rw-r--r--ctrack/caf/templates/caf/caf_detail.html2
-rw-r--r--ctrack/caf/tests/factories.py7
-rw-r--r--ctrack/caf/views.py4
-rw-r--r--ctrack/organisations/templates/organisations/organisation_detail.html2
-rw-r--r--ctrack/templates/pages/stakeholder_home.html2
10 files changed, 80 insertions, 24 deletions
diff --git a/README.rst b/README.rst
index 3d57989..bf8e5b2 100644
--- a/README.rst
+++ b/README.rst
@@ -48,3 +48,8 @@ Bootstrap
python manage.py createsuperuser
python manager.py runserver
+Beartraps
+#########
+
+* Following a migration after a change to the db scheme, ensure that --reuse-db
+ is switched off in Pytest config, otherwise tests will not pass.
diff --git a/ctrack/caf/forms.py b/ctrack/caf/forms.py
index a21488a..9847f01 100644
--- a/ctrack/caf/forms.py
+++ b/ctrack/caf/forms.py
@@ -13,12 +13,13 @@ from ctrack.caf.models import CAF
from ctrack.organisations.models import Organisation
CAFCreateInlineFormset = inlineformset_factory(
- CAF, ApplicableSystem, fields=("name", "organisation"), extra=2)
+ CAF, ApplicableSystem, fields=("name", "organisation"), extra=2
+)
class ApplicableSystemCreateFromCafForm(forms.Form):
- name = forms.CharField(max_length=255)
- description = forms.CharField(widget=forms.Textarea)
+ name = forms.CharField(max_length=255, help_text="System name assigned by OES")
+ function = forms.CharField(widget=forms.Textarea)
organisation = forms.ModelChoiceField(queryset=Organisation.objects.all())
caf = forms.ModelChoiceField(queryset=CAF.objects.all())
@@ -30,26 +31,31 @@ class ApplicableSystemCreateFromCafForm(forms.Form):
super().__init__(*args, **kwargs)
caf = CAF.objects.get(pk=caf_id)
cancel_redirect = reverse("caf:detail", args=[caf_id])
- self.fields['caf'].queryset = CAF.objects.filter(pk=caf_id)
+ self.fields["caf"].queryset = CAF.objects.filter(pk=caf_id)
self.helper = FormHelper(self)
self.helper.layout = Layout(
Fieldset(
"",
Field("name", css_class="form-control-lg"),
- "description",
+ "function",
Hidden("caf", caf_id),
Hidden("organisation", org_id),
),
ButtonHolder(
Submit("submit", "Submit", css_class="btn-primary"),
- Button("cancel", "Cancel", onclick=f"location.href='{cancel_redirect}';", css_class="btn-danger")
- )
+ Button(
+ "cancel",
+ "Cancel",
+ onclick=f"location.href='{cancel_redirect}';",
+ css_class="btn-danger",
+ ),
+ ),
)
class ApplicableSystemCreateFromOrgForm(forms.Form):
name = forms.CharField(max_length=255)
- description = forms.CharField(widget=forms.Textarea)
+ function = forms.CharField(widget=forms.Textarea)
organisation = forms.ModelChoiceField(queryset=Organisation.objects.all())
caf = forms.ModelChoiceField(queryset=CAF.objects.all())
@@ -57,18 +63,25 @@ class ApplicableSystemCreateFromOrgForm(forms.Form):
super().__init__(*args, **kwargs)
cancel_redirect = reverse("organisations:detail", args=[slug])
# we need to create the choices we can use for the CAF dropdown in the form
- self.fields['caf'].queryset = CAF.objects.filter(pk__in=[caf.pk for caf in org_cafs])
+ self.fields["caf"].queryset = CAF.objects.filter(
+ pk__in=[caf.pk for caf in org_cafs]
+ )
self.helper = FormHelper(self)
self.helper.layout = Layout(
Fieldset(
"",
Field("name", css_class="form-control-lg"),
- "description",
+ "function",
Hidden("organisation", org_id),
"caf",
),
ButtonHolder(
Submit("submit", "Submit", css_class="btn-primary"),
- Button("cancel", "Cancel", onclick=f"location.href='{cancel_redirect}';", css_class="btn-danger")
- )
+ Button(
+ "cancel",
+ "Cancel",
+ onclick=f"location.href='{cancel_redirect}';",
+ css_class="btn-danger",
+ ),
+ ),
)
diff --git a/ctrack/caf/migrations/0004_auto_20200813_0953.py b/ctrack/caf/migrations/0004_auto_20200813_0953.py
new file mode 100644
index 0000000..ad1ca96
--- /dev/null
+++ b/ctrack/caf/migrations/0004_auto_20200813_0953.py
@@ -0,0 +1,31 @@
+# Generated by Django 2.2.12 on 2020-08-13 09:53
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('caf', '0003_auto_20200424_1924'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='applicablesystem',
+ options={'verbose_name': 'NIS System'},
+ ),
+ migrations.RemoveField(
+ model_name='applicablesystem',
+ name='description',
+ ),
+ migrations.AddField(
+ model_name='applicablesystem',
+ name='function',
+ field=models.TextField(blank=True, help_text='How the system is relevant to delivering or supporting the essential service', max_length=1000, null=True),
+ ),
+ migrations.AlterField(
+ model_name='applicablesystem',
+ name='name',
+ field=models.CharField(help_text='System name assigned by OES', max_length=256),
+ ),
+ ]
diff --git a/ctrack/caf/models.py b/ctrack/caf/models.py
index 590642f..bfc4765 100644
--- a/ctrack/caf/models.py
+++ b/ctrack/caf/models.py
@@ -54,7 +54,13 @@ class ApplicableSystem(models.Model):
return Organisation.objects.get_or_create(name="DELETED ORGANISATION")[0]
name = models.CharField(max_length=256, help_text="System name assigned by OES")
- description = models.TextField(max_length=1000, blank=True, null=True)
+ function = models.TextField(
+ max_length=1000,
+ blank=True,
+ null=True,
+ help_text="How the system is relevant to delivering or supporting the "
+ "essential service",
+ )
organisation = models.ForeignKey(
Organisation, on_delete=models.SET(get_sentinel_org)
)
@@ -67,7 +73,7 @@ class ApplicableSystem(models.Model):
)
class Meta:
- verbose_name = "Applicable System"
+ verbose_name = "NIS System"
def get_primary_contact(self):
return self.organisation.person_set.filter(primary_nis_contact=True)
diff --git a/ctrack/caf/templates/caf/applicablesystem_detail.html b/ctrack/caf/templates/caf/applicablesystem_detail.html
index 698ee4e..9d695a5 100644
--- a/ctrack/caf/templates/caf/applicablesystem_detail.html
+++ b/ctrack/caf/templates/caf/applicablesystem_detail.html
@@ -12,10 +12,10 @@
<h4>{{ object.name }}</h4>
</div>
<div class="row">
- <h5>Description</h5>
+ <h5>Function</h5>
</div>
<div class="row">
- <p>{{ object.description }}</p>
+ <p>{{ object.function }}</p>
<p>Contained within CAF: to <a href="{% url "caf:detail" object.caf.pk %}">{{ object.caf }}</a></p>
</div>
</div>
diff --git a/ctrack/caf/templates/caf/caf_detail.html b/ctrack/caf/templates/caf/caf_detail.html
index aef275d..97ccad4 100644
--- a/ctrack/caf/templates/caf/caf_detail.html
+++ b/ctrack/caf/templates/caf/caf_detail.html
@@ -71,7 +71,7 @@
{% for system in systems %}
<tr>
<td><a href="{% url "caf:ass_detail" system.id %}">{{ system.name }}</a></td>
- <td>{{ system.description }}<br>
+ <td>{{ system.function }}<br>
<a href="{% url "caf:detail" system.caf.pk %}" class="small">
{{ system.caf }}
</a> <span class="text-muted"> | <a href="#" class="small">Edit System</a></span>
diff --git a/ctrack/caf/tests/factories.py b/ctrack/caf/tests/factories.py
index bc2431e..4c2d5b8 100644
--- a/ctrack/caf/tests/factories.py
+++ b/ctrack/caf/tests/factories.py
@@ -14,8 +14,9 @@ class CAFFactory(factory.DjangoModelFactory):
version = Faker("bothify", text="??##", letters="ABCD")
triage_review_date = Faker("date_object")
triage_review_inspector = factory.SubFactory(PersonFactory)
- comments = Faker("paragraph", nb_sentences=5, variable_nb_sentences=True, ext_word_list=None)
-
+ comments = Faker(
+ "paragraph", nb_sentences=5, variable_nb_sentences=True, ext_word_list=None
+ )
class Meta:
model = CAF
@@ -25,7 +26,7 @@ class ApplicableSystemFactory(factory.DjangoModelFactory):
"""Factory for Essential Services."""
name = Faker("text", max_nb_chars=100, ext_word_list=None)
- description = Faker(
+ function = Faker(
"paragraph", nb_sentences=4, variable_nb_sentences=True, ext_word_list=None
)
organisation = factory.SubFactory(OrganisationFactory)
diff --git a/ctrack/caf/views.py b/ctrack/caf/views.py
index 7345319..258774e 100644
--- a/ctrack/caf/views.py
+++ b/ctrack/caf/views.py
@@ -76,7 +76,7 @@ def applicable_system_create_from_caf(request, caf_id):
if form.is_valid():
ApplicableSystem.objects.create(
name=form.cleaned_data["name"],
- description=form.cleaned_data["description"],
+ function=form.cleaned_data["function"],
caf=form.cleaned_data["caf"],
organisation=form.cleaned_data["organisation"],
)
@@ -106,7 +106,7 @@ class ApplicableSystemCreateFromOrg(
def form_valid(self, form):
ass = ApplicableSystem.objects.create(
name=form.cleaned_data["name"],
- description=form.cleaned_data["description"],
+ function=form.cleaned_data["function"],
organisation=form.cleaned_data["organisation"],
caf=form.cleaned_data["caf"],
)
diff --git a/ctrack/organisations/templates/organisations/organisation_detail.html b/ctrack/organisations/templates/organisations/organisation_detail.html
index bf16c87..af50e1c 100644
--- a/ctrack/organisations/templates/organisations/organisation_detail.html
+++ b/ctrack/organisations/templates/organisations/organisation_detail.html
@@ -78,7 +78,7 @@
{% for ass in applicable_systems %}
<tr>
<td><a href="{% url "caf:ass_detail" ass.id %}">{{ ass.name }}</a></td>
- <td>{{ ass.description }}<br>
+ <td>{{ ass.function }}<br>
<a href="{% url "caf:detail" ass.caf.pk %}" class="small">
{{ ass.caf }}
</a> <span class="text-muted"> | <a href="#" class="small">Edit System</a></span>
diff --git a/ctrack/templates/pages/stakeholder_home.html b/ctrack/templates/pages/stakeholder_home.html
index 5d32771..a0689d8 100644
--- a/ctrack/templates/pages/stakeholder_home.html
+++ b/ctrack/templates/pages/stakeholder_home.html
@@ -142,7 +142,7 @@
{% for system in systems %}
<tr>
<td>{{ system.name }}</td>
- <td>{{ system.description }}</td>
+ <td>{{ system.function }}</td>
<td>{{ system.caf }} | <small><a href="#">Update WebCAF</a></small></td>
</tr>
{% endfor %}