aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctrack/caf/forms.py6
-rw-r--r--ctrack/caf/templates/caf/applicable_system_create_from_org.html14
-rw-r--r--ctrack/caf/urls.py3
-rw-r--r--ctrack/caf/views.py17
4 files changed, 36 insertions, 4 deletions
diff --git a/ctrack/caf/forms.py b/ctrack/caf/forms.py
index 1d07249..776e9af 100644
--- a/ctrack/caf/forms.py
+++ b/ctrack/caf/forms.py
@@ -20,6 +20,12 @@ CAFCreateInlineFormset = inlineformset_factory(
CAF, ApplicableSystem, fields=("name", "organisation"), extra=2)
+class ApplicableSystemCreateFromOrgForm(forms.ModelForm):
+ class Meta:
+ model = ApplicableSystem
+ fields = ["name", "description", "caf"]
+
+
class ApplicableSystemCreateForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
diff --git a/ctrack/caf/templates/caf/applicable_system_create_from_org.html b/ctrack/caf/templates/caf/applicable_system_create_from_org.html
new file mode 100644
index 0000000..4c356e0
--- /dev/null
+++ b/ctrack/caf/templates/caf/applicable_system_create_from_org.html
@@ -0,0 +1,14 @@
+{% extends "base.html" %}
+
+{% load crispy_forms_tags %}
+
+{% block content %}
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6">
+ <p>Creating form for </p>
+ {% crispy form %}
+ </div>
+ </div>
+ </div>
+{% endblock content %}
diff --git a/ctrack/caf/urls.py b/ctrack/caf/urls.py
index 72a1de5..ff1243f 100644
--- a/ctrack/caf/urls.py
+++ b/ctrack/caf/urls.py
@@ -2,7 +2,7 @@ from django.urls import path
from django.views.decorators.cache import cache_page
from ctrack.caf.views import ListCAF, ListApplicableSystem, caf_detail_view, ApplicableSystemDetail, \
- ApplicableSystemCreate
+ ApplicableSystemCreate, ApplicableSystemCreateFromOrg
app_name = "caf"
@@ -10,6 +10,7 @@ urlpatterns = [
path("", view=ListCAF.as_view(), name="caf_list"),
path("applicablesystems", cache_page(60 * 60)(ListApplicableSystem.as_view()), name="es_list"),
path("applicablesystems/<int:pk>", ApplicableSystemDetail.as_view(), name="ass_detail"),
+ path("applicablesystem/<slug:slug>", ApplicableSystemCreateFromOrg.as_view(), name="create_from_org"),
path("applicablesystem/", ApplicableSystemCreate.as_view(), name="create"),
path("<int:pk>", caf_detail_view, name="detail")
]
diff --git a/ctrack/caf/views.py b/ctrack/caf/views.py
index 570700e..141c87e 100644
--- a/ctrack/caf/views.py
+++ b/ctrack/caf/views.py
@@ -4,8 +4,9 @@ from django.urls import reverse_lazy
from django.views.generic import ListView, DetailView, CreateView
from ctrack.assessments.models import CAFAssessmentOutcomeScore
-from ctrack.caf.forms import ApplicableSystemCreateForm
+from ctrack.caf.forms import ApplicableSystemCreateForm, ApplicableSystemCreateFromOrgForm
from ctrack.caf.models import ApplicableSystem, CAF
+from ctrack.organisations.models import Organisation
class ListCAF(LoginRequiredMixin, ListView):
@@ -53,12 +54,22 @@ class ApplicableSystemDetail(LoginRequiredMixin, DetailView):
template_name = "caf/applicablesystem_detail.html"
+class ApplicableSystemCreateFromOrg(LoginRequiredMixin, CreateView):
+ model = ApplicableSystem
+ form_class = ApplicableSystemCreateFromOrgForm
+ template_name = "caf/applicable_system_create_from_org.html"
+
+ def get_context_data(self, **kwargs):
+ org = Organisation.objects.get(slug=self.kwargs["slug"])
+ # TODO - now we have the organisation - we need to pass it to the form or store it in this class.
+ # We probably need to do return super().get_context_data(**kwargs) here to complete the func.
+ pass
+
+
class ApplicableSystemCreate(LoginRequiredMixin, CreateView):
form_class = ApplicableSystemCreateForm
model = ApplicableSystem
template_name = "caf/applicablesystem_create.html"
- success_url = reverse_lazy("caf:es_list")
def get_success_url(self) -> str:
return str(reverse_lazy("caf:ass_detail", args=[self.object.id]))
-