aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/organisations
diff options
context:
space:
mode:
Diffstat (limited to 'ctrack/organisations')
-rw-r--r--ctrack/organisations/models.py4
-rw-r--r--ctrack/organisations/tests/test_views.py13
-rw-r--r--ctrack/organisations/urls.py12
-rw-r--r--ctrack/organisations/views.py7
4 files changed, 34 insertions, 2 deletions
diff --git a/ctrack/organisations/models.py b/ctrack/organisations/models.py
index 6a1b4ac..00e4db6 100644
--- a/ctrack/organisations/models.py
+++ b/ctrack/organisations/models.py
@@ -181,3 +181,7 @@ class Stakeholder(models.Model):
def __str__(self):
return f"{self.person.first_name} {self.person.last_name}"
+
+
+class IncidentReport(models.Model):
+ pass
diff --git a/ctrack/organisations/tests/test_views.py b/ctrack/organisations/tests/test_views.py
index 2111410..1e2476d 100644
--- a/ctrack/organisations/tests/test_views.py
+++ b/ctrack/organisations/tests/test_views.py
@@ -3,6 +3,7 @@ from django.contrib.auth import get_user_model
from django.test import RequestFactory
from ctrack.organisations.tests.factories import OrganisationFactory
+from ctrack.organisations.views import IncidentReportCreateView
from ..views import OrganisationListView
@@ -25,3 +26,15 @@ def test_organisation_list_view():
response = OrganisationListView.as_view()(request)
assert response.status_code == 200
assert len(response.context_data["organisation_list"]) == 3
+
+
+def test_incident_report_create_view():
+ user = get_user_model().objects.create_user(
+ username="testy", email="testy@test.com", password="test1020"
+ )
+ org = OrganisationFactory.create()
+ factory = RequestFactory()
+ request = factory.get(f"{org.name}/create-incident-report")
+ request.user = user
+ response = IncidentReportCreateView.as_view()(request)
+ assert response.status_code == 200
diff --git a/ctrack/organisations/urls.py b/ctrack/organisations/urls.py
index 09743af..5ccfca0 100644
--- a/ctrack/organisations/urls.py
+++ b/ctrack/organisations/urls.py
@@ -1,11 +1,21 @@
from django.urls import path
-from ctrack.organisations.views import OrganisationDetailView, OrganisationListView, OrganisationCreate
+from ctrack.organisations.views import (
+ IncidentReportCreateView,
+ OrganisationCreate,
+ OrganisationDetailView,
+ OrganisationListView,
+)
app_name = "organisations"
urlpatterns = [
path("<slug:slug>/", view=OrganisationDetailView.as_view(), name="detail"),
+ path(
+ "<slug:slug>/create-incident-report/",
+ view=IncidentReportCreateView.as_view(),
+ name="create_incident_report",
+ ),
path("", view=OrganisationListView.as_view(), name="list"),
path("create", view=OrganisationCreate.as_view(), name="create")
# path("create", view=OrganisationCreate.as_view(), name="create")
diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py
index b929de4..3363a33 100644
--- a/ctrack/organisations/views.py
+++ b/ctrack/organisations/views.py
@@ -10,7 +10,7 @@ from django.urls import reverse_lazy
from django.views.generic import CreateView, DetailView, ListView
from .forms import AddressInlineFormSet, OrganisationCreateForm
-from .models import Organisation
+from .models import IncidentReport, Organisation
class OrganisationCreate(LoginRequiredMixin, CreateView):
@@ -71,3 +71,8 @@ class OrganisationDetailView(LoginRequiredMixin, DetailView):
applicable_systems = org.applicablesystem_set.all()
context["applicable_systems"] = applicable_systems
return context
+
+
+class IncidentReportCreateView(LoginRequiredMixin, CreateView):
+ model = IncidentReport
+ fields = "__all__"