From ba1b0f411a6f624e1ebf00c772f25a2dc8479e0c Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Wed, 15 Apr 2020 14:20:29 +0100 Subject: fixing the Ceate CAF page --- ctrack/caf/forms.py | 20 ++++++++++++++++---- ctrack/caf/templates/caf/caf_create.html | 14 ++++++++++++++ ctrack/caf/templates/caf/create.html | 14 -------------- ctrack/caf/views.py | 6 +++--- 4 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 ctrack/caf/templates/caf/caf_create.html delete mode 100644 ctrack/caf/templates/caf/create.html (limited to 'ctrack/caf') diff --git a/ctrack/caf/forms.py b/ctrack/caf/forms.py index fb5e32a..0487682 100644 --- a/ctrack/caf/forms.py +++ b/ctrack/caf/forms.py @@ -12,19 +12,31 @@ from django.urls import reverse from django.forms import ModelChoiceField from ctrack.caf.models import CAF -from ctrack.caf.models import DocumentFile +from ctrack.caf.models import ApplicableSystem, DocumentFile +from ctrack.organisations.models import Organisation +from django.forms.models import ModelMultipleChoiceField -class CAFForm(forms.ModelForm): +class CAFCreateForm(forms.ModelForm): file = ModelChoiceField( queryset=DocumentFile.objects.all(), required=False, help_text="Please select an existing File. Create new File" # 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 = ["file"] + fields = ["quality_grading", "confidence_grading", "version", "file"] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -35,7 +47,7 @@ class CAFForm(forms.ModelForm): self.helper.form_class = "form-group" self.helper.form_method = "post" self.helper.layout = Layout( - Fieldset("Create/Edit CAF", "owner", "file"), + Fieldset("Create/Edit CAF", "owner", "applicable_systems", "quality_grading", "confidence_grading", "file", "version"), ButtonHolder(Submit("submit", "Submit"), Button("cancel", "Cancel")), ) diff --git a/ctrack/caf/templates/caf/caf_create.html b/ctrack/caf/templates/caf/caf_create.html new file mode 100644 index 0000000..822da83 --- /dev/null +++ b/ctrack/caf/templates/caf/caf_create.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} +{% load crispy_forms_tags %} +{% crispy form form.helper %} + + +{% block content %} +
+
+
+ {% crispy form %} +
+
+
+{% endblock %} diff --git a/ctrack/caf/templates/caf/create.html b/ctrack/caf/templates/caf/create.html deleted file mode 100644 index 822da83..0000000 --- a/ctrack/caf/templates/caf/create.html +++ /dev/null @@ -1,14 +0,0 @@ -{% extends "base.html" %} -{% load crispy_forms_tags %} -{% crispy form form.helper %} - - -{% block content %} -
-
-
- {% crispy form %} -
-
-
-{% endblock %} diff --git a/ctrack/caf/views.py b/ctrack/caf/views.py index 6664928..7e5e510 100644 --- a/ctrack/caf/views.py +++ b/ctrack/caf/views.py @@ -3,13 +3,13 @@ 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 CAFForm +from ctrack.caf.forms import CAFCreateForm from ctrack.caf.models import ApplicableSystem, CAF class CreateCAF(LoginRequiredMixin, CreateView): - form_class = CAFForm - template_name = "caf/create.html" + form_class = CAFCreateForm + template_name = "caf/caf_create.html" def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) -- cgit v1.2.3