diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2020-04-20 14:27:18 +0100 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2020-04-20 14:27:18 +0100 |
commit | 324f91f31141fd35ad108142922956893dc4fd3e (patch) | |
tree | 1d2541b09da0c6ec896e09f8a9a04e9d930f10a8 /ctrack/caf/forms.py | |
parent | 792e893a84e916b9aa8be3944f3e905d3bc14fdd (diff) |
part way through configuring the Applicable System create form to control CAF dropdown
Diffstat (limited to '')
-rw-r--r-- | ctrack/caf/forms.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/ctrack/caf/forms.py b/ctrack/caf/forms.py index c1d6595..e9eef3b 100644 --- a/ctrack/caf/forms.py +++ b/ctrack/caf/forms.py @@ -15,16 +15,21 @@ CAFCreateInlineFormset = inlineformset_factory( CAF, ApplicableSystem, fields=("name", "organisation"), extra=2) -class ApplicableSystemCreateFromOrgForm(forms.ModelForm): +class ApplicableSystemCreateFromOrgForm(forms.Form): + choices = () + name = forms.CharField(max_length=255) + description = forms.CharField(widget=forms.Textarea) + organisation = forms.ModelChoiceField(queryset=None) + caf = forms.ChoiceField(choices=( + choices + )) - class Meta: - model = ApplicableSystem - fields = ["name", "description", "caf", "organisation"] - - def __init__(self, org_id, slug, org_name, *args, **kwargs): + def __init__(self, org_id, slug, org_name, org_cafs, *args, **kwargs): super().__init__(*args, **kwargs) cancel_redirect = reverse("organisations:detail", args=[slug]) + ApplicableSystemCreateFromOrgForm.choices = org_cafs self.helper = FormHelper(self) + self.helper.form_method = "post" self.helper.layout = Layout( Fieldset( f"Create a new system for {org_name}", @@ -38,4 +43,3 @@ class ApplicableSystemCreateFromOrgForm(forms.ModelForm): Button("cancel", "Cancel", onclick=f"location.href='{cancel_redirect}';", css_class="btn-danger") ) ) - |