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.py38
1 files changed, 21 insertions, 17 deletions
diff --git a/ctrack/caf/forms.py b/ctrack/caf/forms.py
index 7367ccd..8e3d8ee 100644
--- a/ctrack/caf/forms.py
+++ b/ctrack/caf/forms.py
@@ -12,12 +12,13 @@ from django import forms
from django.forms import inlineformset_factory
from django.urls import reverse
-from ctrack.caf.models import CAF, ApplicableSystem
+from ctrack.caf.models import CAF, ApplicableSystem, EssentialService
from ctrack.organisations.models import Organisation
-CAFCreateInlineFormset = inlineformset_factory(
- CAF, ApplicableSystem, fields=("name", "organisation"), extra=2
-)
+# TODO - Replace this to get inlineformet working
+# CAFCreateInlineFormset = inlineformset_factory(
+# CAF, ApplicableSystem, fields=("name", "organisation"), extra=2
+# )
class ApplicableSystemCreateFromCafForm(forms.Form):
@@ -77,13 +78,14 @@ class ApplicableSystemCreateFromCafForm(forms.Form):
class ApplicableSystemCreateFromOrgForm(forms.Form):
name = forms.CharField(max_length=255)
function = forms.CharField(widget=forms.Textarea)
- organisation = forms.ModelChoiceField(queryset=Organisation.objects.all())
- caf = forms.ModelChoiceField(queryset=CAF.objects.all())
- essential_service = forms.CharField(
- widget=forms.Textarea,
- max_length=255,
- help_text="Description of the essential service which the system suppports.",
- )
+ # organisation = forms.ModelChoiceField(queryset=Organisation.objects.all())
+ # caf = forms.ModelChoiceField(queryset=CAF.objects.all())
+ # essential_service = forms.CharField(
+ # widget=forms.Textarea,
+ # max_length=255,
+ # help_text="Description of the essential service which the system suppports.",
+ # )
+ essential_service = forms.ModelChoiceField(queryset=EssentialService.objects.all())
dft_categorisation = forms.ChoiceField(
choices=ApplicableSystem.SYSTEM_CATEGORISATION,
help_text="Refer to documentation for description of these criteria",
@@ -93,16 +95,19 @@ class ApplicableSystemCreateFromOrgForm(forms.Form):
help_text="Categorisation based on OES' own internal prioritisation process.",
)
- def __init__(self, org_id, slug, org_name, org_cafs, *args, **kwargs):
+ def __init__(self, org_id, slug, org_name, *args, **kwargs):
super().__init__(*args, **kwargs)
cancel_redirect = reverse("organisations:detail", args=[slug])
# we need to create the choices we can use for the CAF dropdown in the form
- self.fields["caf"].queryset = CAF.objects.filter(
- pk__in=[caf.pk for caf in org_cafs]
- )
- self.fields["caf"].label = "CAF"
+ # self.fields["caf"].queryset = CAF.objects.filter(
+ # pk__in=[caf.pk for caf in org_cafs]
+ # )
+ # self.fields["caf"].label = "CAF"
self.fields["dft_categorisation"].label = "DfT Categorisation"
self.fields["oes_categorisation"].label = "OES Categorisation"
+ self.fields["essential_service"].queryset = EssentialService.objects.filter(
+ pk=org_id
+ )
self.helper = FormHelper(self)
self.helper.layout = Layout(
Fieldset(
@@ -113,7 +118,6 @@ class ApplicableSystemCreateFromOrgForm(forms.Form):
"dft_categorisation",
"oes_categorisation",
Hidden("organisation", org_id),
- "caf",
),
ButtonHolder(
Submit("submit", "Submit", css_class="btn-primary"),