aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/settings/base.py2
-rw-r--r--config/urls.py7
-rw-r--r--ctrack/caf/__init__.py0
-rw-r--r--ctrack/caf/admin.py10
-rw-r--r--ctrack/caf/apps.py6
-rw-r--r--ctrack/caf/forms.py26
-rw-r--r--ctrack/caf/migrations/0001_initial.py59
-rw-r--r--ctrack/caf/migrations/__init__.py0
-rw-r--r--ctrack/caf/models.py61
-rw-r--r--ctrack/caf/templates/caf/create.html14
-rw-r--r--ctrack/caf/tests.py3
-rw-r--r--ctrack/caf/urls.py9
-rw-r--r--ctrack/caf/views.py17
-rw-r--r--ctrack/register/__init__.py0
-rw-r--r--ctrack/register/admin.py3
-rw-r--r--ctrack/register/apps.py5
-rw-r--r--ctrack/register/migrations/__init__.py0
-rw-r--r--ctrack/register/models.py3
-rw-r--r--ctrack/register/tests.py3
-rw-r--r--ctrack/register/urls.py5
-rw-r--r--ctrack/register/views.py3
-rw-r--r--mypy.ini41
22 files changed, 276 insertions, 1 deletions
diff --git a/config/settings/base.py b/config/settings/base.py
index fa52962..83317ca 100644
--- a/config/settings/base.py
+++ b/config/settings/base.py
@@ -77,6 +77,8 @@ THIRD_PARTY_APPS = [
LOCAL_APPS = [
"ctrack.users.apps.UsersConfig",
"ctrack.organisations.apps.OrganisationsConfig",
+ "ctrack.caf.apps.CafConfig",
+ "ctrack.register.apps.RegisterConfig",
# Your stuff: custom apps go here
]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
diff --git a/config/urls.py b/config/urls.py
index a9a9108..cd7f6f2 100644
--- a/config/urls.py
+++ b/config/urls.py
@@ -17,7 +17,12 @@ urlpatterns = [
path(settings.ADMIN_URL, admin.site.urls),
# User management
path("users/", include("ctrack.users.urls", namespace="users")),
- path("organisations/", include("ctrack.organisations.urls", namespace="organisations")),
+ path(
+ "organisations/",
+ include("ctrack.organisations.urls", namespace="organisations"),
+ ),
+ path("register/", include("ctrack.organisations.urls", namespace="register")),
+ path("caf/", include("ctrack.caf.urls", namespace="caf")),
path("accounts/", include("allauth.urls")),
# Your stuff: custom urls includes go here
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
diff --git a/ctrack/caf/__init__.py b/ctrack/caf/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ctrack/caf/__init__.py
diff --git a/ctrack/caf/admin.py b/ctrack/caf/admin.py
new file mode 100644
index 0000000..c0f416e
--- /dev/null
+++ b/ctrack/caf/admin.py
@@ -0,0 +1,10 @@
+from django.contrib import admin
+
+from .models import CAF, CAFFileStore, DocumentFile, Ranking
+
+# Register your models here.
+
+admin.site.register(CAF)
+admin.site.register(CAFFileStore)
+admin.site.register(DocumentFile)
+admin.site.register(Ranking)
diff --git a/ctrack/caf/apps.py b/ctrack/caf/apps.py
new file mode 100644
index 0000000..d8ae85f
--- /dev/null
+++ b/ctrack/caf/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class CafConfig(AppConfig):
+ name = 'ctrack.caf'
+ verbose_name = "CAF Register"
diff --git a/ctrack/caf/forms.py b/ctrack/caf/forms.py
new file mode 100644
index 0000000..ee3bf21
--- /dev/null
+++ b/ctrack/caf/forms.py
@@ -0,0 +1,26 @@
+from crispy_forms.helper import FormHelper
+from crispy_forms.layout import Button
+from crispy_forms.layout import ButtonHolder
+from crispy_forms.layout import Fieldset
+from crispy_forms.layout import Layout
+from crispy_forms.layout import Submit
+from django import forms
+
+from ctrack.caf.models import CAF
+
+
+class CAFForm(forms.ModelForm):
+ class Meta:
+ model = CAF
+ fields = ["owner", "essential_system"]
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+
+ self.helper = FormHelper(self)
+ self.helper.form_class = "form-group"
+ self.helper.form_method = "post"
+ self.helper.layout = Layout(
+ Fieldset("Create/Edit CAF", "owner", "essential_system"),
+ ButtonHolder(Submit("submit", "Submit"), Button("cancel", "Cancel")),
+ )
diff --git a/ctrack/caf/migrations/0001_initial.py b/ctrack/caf/migrations/0001_initial.py
new file mode 100644
index 0000000..8e0b11a
--- /dev/null
+++ b/ctrack/caf/migrations/0001_initial.py
@@ -0,0 +1,59 @@
+# Generated by Django 2.2.9 on 2020-01-25 16:56
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ('organisations', '0014_auto_20200125_1459'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='CAFFileStore',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('descriptor', models.CharField(max_length=100)),
+ ('virtual_location', models.CharField(help_text='USB, Rosa, email, etc', max_length=100)),
+ ('physical_location', models.CharField(blank=True, help_text='Cupboard, room, building, etc', max_length=100)),
+ ('physical_location_organisation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.Organisation')),
+ ],
+ options={
+ 'verbose_name': 'CAF File Store',
+ },
+ ),
+ migrations.CreateModel(
+ name='Ranking',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('descriptor', models.CharField(max_length=100)),
+ ('type', models.IntegerField(choices=[(1, 'Triage'), (2, 'First Assessment')], default=1)),
+ ],
+ ),
+ migrations.CreateModel(
+ name='DocumentFile',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=255)),
+ ('type', models.IntegerField(choices=[(1, 'Excel'), (2, 'Word'), (3, 'PDF'), (4, 'Hard Copy')], default=1)),
+ ('file_store_location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='caf.CAFFileStore')),
+ ],
+ ),
+ migrations.CreateModel(
+ name='CAF',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('essential_system', models.CharField(blank=True, max_length=255)),
+ ('file', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='caf.DocumentFile')),
+ ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.Organisation')),
+ ('triage_ranking', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='caf.Ranking')),
+ ],
+ options={
+ 'verbose_name': 'CAF',
+ },
+ ),
+ ]
diff --git a/ctrack/caf/migrations/__init__.py b/ctrack/caf/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ctrack/caf/migrations/__init__.py
diff --git a/ctrack/caf/models.py b/ctrack/caf/models.py
new file mode 100644
index 0000000..53faabf
--- /dev/null
+++ b/ctrack/caf/models.py
@@ -0,0 +1,61 @@
+from django.db import models
+
+from ctrack.organisations.models import Organisation
+
+# TODO - thinking about whether TriageAssessment can be converted into an inherited class
+# e.g. we inherit from
+# class Assessment(models.Model):
+# descriptor = models.CharField(max_length=100)
+# date_entered = models.DateTimeField(auto_now_add=True)
+# modified = models.DateTimeField(auto_now=True)
+#
+# class Meta:
+# abstract = True
+
+
+class Ranking(models.Model):
+ RANKING_TYPE = [(1, "Triage"), (2, "First Assessment")]
+ descriptor = models.CharField(max_length=100)
+ type = models.IntegerField(choices=RANKING_TYPE, default=1)
+
+ def __str__(self):
+ return self.descriptor
+
+
+class CAFFileStore(models.Model):
+ descriptor = models.CharField(max_length=100)
+ virtual_location = models.CharField(
+ max_length=100, help_text="USB, Rosa, email, etc"
+ )
+ physical_location = models.CharField(
+ max_length=100, blank=True, help_text="Cupboard, room, building, etc"
+ ) # cupboard, room, building, address
+ physical_location_organisation = models.ForeignKey(
+ Organisation, on_delete=models.CASCADE
+ )
+
+ class Meta:
+ verbose_name = "CAF File Store"
+
+
+class DocumentFile(models.Model):
+ FILETYPE_CHOICES = [(1, "Excel"), (2, "Word"), (3, "PDF"), (4, "Hard Copy")]
+ name = models.CharField(max_length=255)
+ type = models.IntegerField(choices=FILETYPE_CHOICES, default=1)
+ file_store_location = models.ForeignKey(CAFFileStore, on_delete=models.CASCADE)
+
+
+class CAF(models.Model):
+ owner = models.ForeignKey(Organisation, on_delete=models.CASCADE)
+ essential_system = models.CharField(max_length=255, blank=True)
+ triage_ranking = models.ForeignKey(Ranking, on_delete=models.CASCADE)
+ file = models.ForeignKey(DocumentFile, on_delete=models.CASCADE)
+
+ def __str__(self):
+ if not self.essential_system:
+ return f"Comprehensive CAF for {self.owner}"
+ else:
+ return f"{self.essential_system} CAF for {self.owner}"
+
+ class Meta:
+ verbose_name = "CAF"
diff --git a/ctrack/caf/templates/caf/create.html b/ctrack/caf/templates/caf/create.html
new file mode 100644
index 0000000..822da83
--- /dev/null
+++ b/ctrack/caf/templates/caf/create.html
@@ -0,0 +1,14 @@
+{% extends "base.html" %}
+{% load crispy_forms_tags %}
+{% crispy form form.helper %}
+
+
+{% block content %}
+<div class="container">
+ <div class="row">
+ <div class="col-lg-6">
+ {% crispy form %}
+ </div>
+ </div>
+</div>
+{% endblock %}
diff --git a/ctrack/caf/tests.py b/ctrack/caf/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/ctrack/caf/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/ctrack/caf/urls.py b/ctrack/caf/urls.py
new file mode 100644
index 0000000..e819ef7
--- /dev/null
+++ b/ctrack/caf/urls.py
@@ -0,0 +1,9 @@
+from django.urls import path
+
+from ctrack.caf.views import CreateCAF
+
+app_name = "caf"
+
+urlpatterns = [
+ path("", view=CreateCAF.as_view(), name="create")
+]
diff --git a/ctrack/caf/views.py b/ctrack/caf/views.py
new file mode 100644
index 0000000..b46360b
--- /dev/null
+++ b/ctrack/caf/views.py
@@ -0,0 +1,17 @@
+from django.views.generic import CreateView
+
+from ctrack.caf.forms import CAFForm
+
+
+class CreateCAF(CreateView):
+ form_class = CAFForm
+ template_name = "caf/create.html"
+
+ def get_context_data(self, **kwargs):
+ context = super().get_context_data(**kwargs)
+ context['form'] = self.form_class
+ return context
+
+
+
+
diff --git a/ctrack/register/__init__.py b/ctrack/register/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ctrack/register/__init__.py
diff --git a/ctrack/register/admin.py b/ctrack/register/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/ctrack/register/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/ctrack/register/apps.py b/ctrack/register/apps.py
new file mode 100644
index 0000000..0e94c46
--- /dev/null
+++ b/ctrack/register/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class RegisterConfig(AppConfig):
+ name = 'register'
diff --git a/ctrack/register/migrations/__init__.py b/ctrack/register/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ctrack/register/migrations/__init__.py
diff --git a/ctrack/register/models.py b/ctrack/register/models.py
new file mode 100644
index 0000000..71a8362
--- /dev/null
+++ b/ctrack/register/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/ctrack/register/tests.py b/ctrack/register/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/ctrack/register/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/ctrack/register/urls.py b/ctrack/register/urls.py
new file mode 100644
index 0000000..f323e45
--- /dev/null
+++ b/ctrack/register/urls.py
@@ -0,0 +1,5 @@
+from django.urls import path
+
+app_name = "register"
+
+
diff --git a/ctrack/register/views.py b/ctrack/register/views.py
new file mode 100644
index 0000000..91ea44a
--- /dev/null
+++ b/ctrack/register/views.py
@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.
diff --git a/mypy.ini b/mypy.ini
new file mode 100644
index 0000000..b34419c
--- /dev/null
+++ b/mypy.ini
@@ -0,0 +1,41 @@
+### THESE ARE DEFAULTS PROVIDED FOR flake8-mypy plugin
+### If needed for bare mypy run, add --config-file command
+### Can be applied to flake8 with --mypy-config - both of these pointing to this file
+[mypy]
+# Specify the target platform details in config, so your developers are
+# free to run mypy on Windows, Linux, or macOS and get consistent
+# results.
+python_version=3.8
+platform=linux
+
+# follow imports -normal is default and not requied, but anyway
+follow_imports=normal
+
+# flake8-mypy expects the two following for sensible formatting
+show_column_numbers=True
+show_error_context=False
+
+# suppress errors about unsatisfied imports
+ignore_missing_imports=True
+
+# allow untyped calls as a consequence of the options above
+disallow_untyped_calls=False
+
+# allow returning Any as a consequence of the options above
+warn_return_any=True
+
+# treat Optional per PEP 484
+strict_optional=True
+
+# ensure all execution paths are returning
+warn_no_return=True
+
+# lint-style cleanliness for typing needs to be disabled; returns more errors
+# than the full run.
+warn_redundant_casts=False
+warn_unused_ignores=False
+
+# The following are off by default since they're too noisy.
+# Flip them on if you feel adventurous.
+disallow_untyped_defs=False
+check_untyped_defs=False