aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/organisations
diff options
context:
space:
mode:
Diffstat (limited to 'ctrack/organisations')
-rw-r--r--ctrack/organisations/migrations/0001_initial.py96
-rw-r--r--ctrack/organisations/migrations/0002_auto_20201015_1955.py26
-rw-r--r--ctrack/organisations/migrations/0002_auto_20201021_1551.py55
-rw-r--r--ctrack/organisations/templates/organisations/organisation_detail.html2
-rw-r--r--ctrack/organisations/tests/factories.py2
-rw-r--r--ctrack/organisations/views.py2
6 files changed, 101 insertions, 82 deletions
diff --git a/ctrack/organisations/migrations/0001_initial.py b/ctrack/organisations/migrations/0001_initial.py
index c5ab495..e13cafb 100644
--- a/ctrack/organisations/migrations/0001_initial.py
+++ b/ctrack/organisations/migrations/0001_initial.py
@@ -1,6 +1,5 @@
-# Generated by Django 2.2.12 on 2020-08-27 09:40
+# Generated by Django 3.1.2 on 2020-10-21 15:51
-import django.contrib.auth
from django.db import migrations, models
import django.db.models.deletion
import django_extensions.db.fields
@@ -15,6 +14,23 @@ class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
+ name='Address',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('line1', models.CharField(max_length=255)),
+ ('line2', models.CharField(blank=True, max_length=255)),
+ ('line3', models.CharField(blank=True, max_length=255)),
+ ('city', models.CharField(max_length=100)),
+ ('county', models.CharField(blank=True, max_length=100)),
+ ('postcode', models.CharField(max_length=10)),
+ ('country', models.CharField(max_length=100)),
+ ('other_details', models.CharField(blank=True, max_length=255)),
+ ],
+ options={
+ 'verbose_name_plural': 'Addresses',
+ },
+ ),
+ migrations.CreateModel(
name='AddressType',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
@@ -22,6 +38,27 @@ class Migration(migrations.Migration):
],
),
migrations.CreateModel(
+ name='IncidentReport',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('person_involved', models.CharField(blank=True, max_length=100, verbose_name='Name of person reporting/detecting incident')),
+ ('role', models.CharField(blank=True, help_text='Role of person reporting/detecting incident', max_length=100)),
+ ('phone_number', models.CharField(max_length=30)),
+ ('email', models.EmailField(max_length=254)),
+ ('internal_incident_number', models.CharField(blank=True, max_length=30)),
+ ('date_time_incident_detected', models.DateTimeField(verbose_name='Date/Time incident detected')),
+ ('date_time_incident_reported', models.DateTimeField(auto_now=True, verbose_name='Date/Time incident reported')),
+ ('incident_type', models.CharField(choices=[('Cyber', 'Cyber'), ('Non-Cyber', 'Non-Cyber'), ('Both', 'Both'), ('Power Outage', 'Power Outage')], help_text='This can be appoximate', max_length=20)),
+ ('incident_status', models.CharField(choices=[('Detected', 'Detected'), ('Suspected', 'Suspected'), ('Resolved', 'Resolved')], max_length=20)),
+ ('incident_stage', models.CharField(choices=[('Ongoing', 'Ongoing'), ('Ended', 'Ended'), ('Ongoing but managed', 'Ongoing but managed')], max_length=20)),
+ ('summary', models.TextField(help_text='Please provide a summary of your understanding of the incident, including any impact to services and/or users.')),
+ ('mitigations', models.TextField(help_text='What investigations and/or mitigations have you or a third party performed or plan to perform?', verbose_name='Investigations or mitigations')),
+ ('others_informed', models.TextField(help_text='Who else has been informed about this incident?(CSIRT, NCSC, NCA, etc)', verbose_name='Others parties informed')),
+ ('next_steps', models.TextField(help_text='What are your planned next steps?', verbose_name='Planned next steps')),
+ ('dft_handle_status', models.CharField(choices=[('QUEUED', 'QUEUED'), ('REVIEWING', 'REVIEWING'), ('WAITING', 'WAITING'), ('COMPLETED', 'COMPLETED')], default='QUEUED', max_length=20)),
+ ],
+ ),
+ migrations.CreateModel(
name='Mode',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
@@ -67,8 +104,8 @@ class Migration(migrations.Migration):
('active', models.BooleanField(default=True)),
('date_ended', models.DateField(blank=True, null=True)),
('comments', models.TextField(blank=True, max_length=1000)),
- ('organisation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.Organisation')),
- ('predecessor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='previous_person', to='organisations.Person')),
+ ('organisation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.organisation')),
+ ('predecessor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='previous_person', to='organisations.person')),
],
options={
'verbose_name_plural': 'People',
@@ -86,14 +123,14 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('descriptor', models.CharField(max_length=100)),
- ('mode', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.Mode')),
+ ('mode', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.mode')),
],
),
migrations.CreateModel(
name='Stakeholder',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('person', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.Person')),
+ ('person', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.person')),
],
),
migrations.AddField(
@@ -101,51 +138,4 @@ class Migration(migrations.Migration):
name='role',
field=models.ManyToManyField(to='organisations.Role'),
),
- migrations.AddField(
- model_name='organisation',
- name='submode',
- field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='organisations.Submode'),
- ),
- migrations.CreateModel(
- name='IncidentReport',
- fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('person_involved', models.CharField(blank=True, max_length=100, verbose_name='Name of person reporting/detecting incident')),
- ('role', models.CharField(blank=True, help_text='Role of person reporting/detecting incident', max_length=100)),
- ('phone_number', models.CharField(max_length=30)),
- ('email', models.EmailField(max_length=254)),
- ('internal_incident_number', models.CharField(blank=True, max_length=30)),
- ('date_time_incident_detected', models.DateTimeField(verbose_name='Date/Time incident detected')),
- ('date_time_incident_reported', models.DateTimeField(auto_now=True, verbose_name='Date/Time incident reported')),
- ('incident_type', models.CharField(choices=[('Cyber', 'Cyber'), ('Non-Cyber', 'Non-Cyber'), ('Both', 'Both'), ('Power Outage', 'Power Outage')], help_text='This can be appoximate', max_length=20)),
- ('incident_status', models.CharField(choices=[('Detected', 'Detected'), ('Suspected', 'Suspected'), ('Resolved', 'Resolved')], max_length=20)),
- ('incident_stage', models.CharField(choices=[('Ongoing', 'Ongoing'), ('Ended', 'Ended'), ('Ongoing but managed', 'Ongoing but managed')], max_length=20)),
- ('summary', models.TextField(help_text='Please provide a summary of your understanding of the incident, including any impact to services and/or users.')),
- ('mitigations', models.TextField(help_text='What investigations and/or mitigations have you or a third party performed or plan to perform?', verbose_name='Investigations or mitigations')),
- ('others_informed', models.TextField(help_text='Who else has been informed about this incident?(CSIRT, NCSC, NCA, etc)', verbose_name='Others parties informed')),
- ('next_steps', models.TextField(help_text='What are your planned next steps?', verbose_name='Planned next steps')),
- ('dft_handle_status', models.CharField(choices=[('QUEUED', 'QUEUED'), ('REVIEWING', 'REVIEWING'), ('WAITING', 'WAITING'), ('COMPLETED', 'COMPLETED')], default='QUEUED', max_length=20)),
- ('organisation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.Organisation')),
- ('reporting_person', models.ForeignKey(on_delete=models.SET(django.contrib.auth.get_user_model), to='organisations.Person', verbose_name='Person reporting the incident')),
- ],
- ),
- migrations.CreateModel(
- name='Address',
- fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('line1', models.CharField(max_length=255)),
- ('line2', models.CharField(blank=True, max_length=255)),
- ('line3', models.CharField(blank=True, max_length=255)),
- ('city', models.CharField(max_length=100)),
- ('county', models.CharField(blank=True, max_length=100)),
- ('postcode', models.CharField(max_length=10)),
- ('country', models.CharField(max_length=100)),
- ('other_details', models.CharField(blank=True, max_length=255)),
- ('organisation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='addresses', to='organisations.Organisation')),
- ('type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.AddressType', verbose_name='Address Type')),
- ],
- options={
- 'verbose_name_plural': 'Addresses',
- },
- ),
]
diff --git a/ctrack/organisations/migrations/0002_auto_20201015_1955.py b/ctrack/organisations/migrations/0002_auto_20201015_1955.py
deleted file mode 100644
index dcc2463..0000000
--- a/ctrack/organisations/migrations/0002_auto_20201015_1955.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# Generated by Django 3.1.2 on 2020-10-15 19:55
-
-import ctrack.organisations.models
-from django.conf import settings
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- migrations.swappable_dependency(settings.AUTH_USER_MODEL),
- ('organisations', '0001_initial'),
- ]
-
- operations = [
- migrations.AddField(
- model_name='organisation',
- name='deputy_lead_inspector',
- field=models.ForeignKey(null=True, on_delete=models.SET(ctrack.organisations.models.Organisation.get_sentinel_user), related_name='deputy_inspector', to=settings.AUTH_USER_MODEL),
- ),
- migrations.AddField(
- model_name='organisation',
- name='lead_inspector',
- field=models.ForeignKey(null=True, on_delete=models.SET(ctrack.organisations.models.Organisation.get_sentinel_user), related_name='lead_inspector', to=settings.AUTH_USER_MODEL),
- ),
- ]
diff --git a/ctrack/organisations/migrations/0002_auto_20201021_1551.py b/ctrack/organisations/migrations/0002_auto_20201021_1551.py
new file mode 100644
index 0000000..b9afa58
--- /dev/null
+++ b/ctrack/organisations/migrations/0002_auto_20201021_1551.py
@@ -0,0 +1,55 @@
+# Generated by Django 3.1.2 on 2020-10-21 15:51
+
+import ctrack.organisations.models
+from django.conf import settings
+import django.contrib.auth
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ('organisations', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='organisation',
+ name='deputy_lead_inspector',
+ field=models.ForeignKey(null=True, on_delete=models.SET(ctrack.organisations.models.Organisation.get_sentinel_user), related_name='deputy_inspector', to=settings.AUTH_USER_MODEL),
+ ),
+ migrations.AddField(
+ model_name='organisation',
+ name='lead_inspector',
+ field=models.ForeignKey(null=True, on_delete=models.SET(ctrack.organisations.models.Organisation.get_sentinel_user), related_name='lead_inspector', to=settings.AUTH_USER_MODEL),
+ ),
+ migrations.AddField(
+ model_name='organisation',
+ name='submode',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='organisations.submode'),
+ ),
+ migrations.AddField(
+ model_name='incidentreport',
+ name='organisation',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.organisation'),
+ ),
+ migrations.AddField(
+ model_name='incidentreport',
+ name='reporting_person',
+ field=models.ForeignKey(on_delete=models.SET(django.contrib.auth.get_user_model), to='organisations.person', verbose_name='Person reporting the incident'),
+ ),
+ migrations.AddField(
+ model_name='address',
+ name='organisation',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='addresses', to='organisations.organisation'),
+ ),
+ migrations.AddField(
+ model_name='address',
+ name='type',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.addresstype', verbose_name='Address Type'),
+ ),
+ ]
diff --git a/ctrack/organisations/templates/organisations/organisation_detail.html b/ctrack/organisations/templates/organisations/organisation_detail.html
index cb5a54d..fe744fe 100644
--- a/ctrack/organisations/templates/organisations/organisation_detail.html
+++ b/ctrack/organisations/templates/organisations/organisation_detail.html
@@ -150,7 +150,7 @@
</h5>
<div class="card-subtitle mb-2">
<span class="badge badge-info">{{ event.type_descriptor }}</span>
- <span class="badge badge-light">{{ event.datetime|date:"l j F Y" }}, {{ event.datetime|date:"G:i" }}</span></h5>
+ <span class="badge badge-light">{{ event.date|date:"l j F Y" }}, {{ event.datetime|date:"G:i" }}</span></h5>
</div>
<p class="card-text">{{ event.comments }}</p>
Participants:
diff --git a/ctrack/organisations/tests/factories.py b/ctrack/organisations/tests/factories.py
index 330ad79..22f6430 100644
--- a/ctrack/organisations/tests/factories.py
+++ b/ctrack/organisations/tests/factories.py
@@ -125,7 +125,7 @@ class AddressFactory(DjangoModelFactory):
class SingleDateTimeEventFactory(DjangoModelFactory):
type_descriptor = None # must pass this in
short_description = "Nothing short description"
- datetime = "2020-02-10 10:00"
+ date = "2020-02-10 10:00"
comments = "Nothing comments"
location = "Gark's basin"
user = SubFactory(UserFactory)
diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py
index 5726aa2..324f933 100644
--- a/ctrack/organisations/views.py
+++ b/ctrack/organisations/views.py
@@ -122,7 +122,7 @@ class OrganisationDetailView(PermissionRequiredMixin, DetailView):
]
flat_sdes = sorted(
list(itertools.chain.from_iterable(_sdes)),
- key=lambda e: e.datetime,
+ key=lambda e: e.date,
reverse=True,
)