aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/caf/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'ctrack/caf/forms.py')
-rw-r--r--ctrack/caf/forms.py39
1 files changed, 3 insertions, 36 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)