aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/caf
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-04-16 15:02:40 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-04-16 15:02:40 +0100
commit7d13d652b741bee7390c39d6e27f4e6f9d909442 (patch)
tree781adeeb159a5418596db2b2bd199b2ec205204a /ctrack/caf
parent82fa2dabf282971a81ee16858aa5513c51cb7d56 (diff)
removed CAFCreate form view and template - we're not doing that outside admin
Diffstat (limited to 'ctrack/caf')
-rw-r--r--ctrack/caf/forms.py39
-rw-r--r--ctrack/caf/templates/caf/caf_create.html14
-rw-r--r--ctrack/caf/urls.py3
-rw-r--r--ctrack/caf/views.py21
4 files changed, 9 insertions, 68 deletions
diff --git a/ctrack/caf/forms.py b/ctrack/caf/forms.py
index 0487682..fac3049 100644
--- a/ctrack/caf/forms.py
+++ b/ctrack/caf/forms.py
@@ -9,45 +9,12 @@ from django import forms
from django.urls import reverse
-from django.forms import ModelChoiceField
+from django.forms import inlineformset_factory
from ctrack.caf.models import CAF
from ctrack.caf.models import ApplicableSystem, DocumentFile
from ctrack.organisations.models import Organisation
from django.forms.models import ModelMultipleChoiceField
-
-class CAFCreateForm(forms.ModelForm):
- file = ModelChoiceField(
- queryset=DocumentFile.objects.all(),
- required=False,
- help_text="Please select an existing File. <a href='/caf/file/documentfile/create' target='_blank'>Create new File</a>" # TODO this URL does not exist
- )
- owner = ModelChoiceField(
- queryset=Organisation.objects.all(),
- required=True,
- help_text="Choose the Organisation that owns this CAF."
- )
- applicable_systems = ModelMultipleChoiceField(
- queryset=ApplicableSystem.objects.all(),
- required=True,
- help_text="Choose the system."
- )
-
- class Meta:
- model = CAF
- fields = ["quality_grading", "confidence_grading", "version", "file"]
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
-
- cancel_redirect = reverse('caf:caf_list') # TODO this URL doesn't exist
-
- self.helper = FormHelper(self)
- self.helper.form_class = "form-group"
- self.helper.form_method = "post"
- self.helper.layout = Layout(
- Fieldset("Create/Edit CAF", "owner", "applicable_systems", "quality_grading", "confidence_grading", "file", "version"),
- ButtonHolder(Submit("submit", "Submit"), Button("cancel", "Cancel")),
- )
-
+CAFCreateInlineFormset = inlineformset_factory(
+ CAF, ApplicableSystem, fields=("name", "organisation"), extra=2)
diff --git a/ctrack/caf/templates/caf/caf_create.html b/ctrack/caf/templates/caf/caf_create.html
deleted file mode 100644
index 822da83..0000000
--- a/ctrack/caf/templates/caf/caf_create.html
+++ /dev/null
@@ -1,14 +0,0 @@
-{% 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/urls.py b/ctrack/caf/urls.py
index dc5bc44..a9b7946 100644
--- a/ctrack/caf/urls.py
+++ b/ctrack/caf/urls.py
@@ -1,12 +1,11 @@
from django.urls import path
from django.views.decorators.cache import cache_page
-from ctrack.caf.views import CreateCAF, ListCAF, ListApplicableSystem, caf_detail_view
+from ctrack.caf.views import ListCAF, ListApplicableSystem, caf_detail_view
app_name = "caf"
urlpatterns = [
- path("", view=CreateCAF.as_view(), name="create"),
path("", view=ListCAF.as_view(), name="caf_list"),
path("applicablesystems", cache_page(60 * 60)(ListApplicableSystem.as_view()), name="es_list"),
path("<int:pk>", caf_detail_view, name="detail")
diff --git a/ctrack/caf/views.py b/ctrack/caf/views.py
index 7e5e510..c33b2d1 100644
--- a/ctrack/caf/views.py
+++ b/ctrack/caf/views.py
@@ -3,26 +3,15 @@ from django.shortcuts import render
from django.views.generic import CreateView, ListView, DetailView
from ctrack.assessments.models import CAFAssessment, CAFObjective, CAFPrinciple, CAFAssessmentOutcomeScore
-from ctrack.caf.forms import CAFCreateForm
from ctrack.caf.models import ApplicableSystem, CAF
-class CreateCAF(LoginRequiredMixin, CreateView):
- form_class = CAFCreateForm
- template_name = "caf/caf_create.html"
-
- def get_context_data(self, **kwargs):
- context = super().get_context_data(**kwargs)
- context['form'] = self.form_class
- return context
-
-
-class ListCAF(LoginRequiredMixin, ListView):
- pass
-
-
-# class DetailCAF(LoginRequiredMixin, DetailView):
+# class ListCAF(LoginRequiredMixin, ListView):
# model = CAF
+# paginate_by = 20
+
+# def get_context_data(self, **kwargs):
+# return super().get_context_data(**kwargs)
# Let's write a traditional function view!
def caf_detail_view(request, pk):