diff options
author | MR Lemon <matt@matthewlemon> | 2020-05-01 16:28:08 +0100 |
---|---|---|
committer | MR Lemon <matt@matthewlemon> | 2020-05-01 16:56:30 +0100 |
commit | dbe4555b17e2dd0d49b8c4879252692f75f8fe42 (patch) | |
tree | e9e308d6f49d5419096996674a36906f81da9a51 /ctrack/organisations/forms.py | |
parent | efde7c98c202405c4bbbd9d8832f3f92fc402468 (diff) |
squashed a lot of wizard form code
Diffstat (limited to '')
-rw-r--r-- | ctrack/organisations/forms.py | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/ctrack/organisations/forms.py b/ctrack/organisations/forms.py index d9495f8..d4baf64 100644 --- a/ctrack/organisations/forms.py +++ b/ctrack/organisations/forms.py @@ -9,20 +9,32 @@ from ctrack.organisations.models import Organisation, Address class OrganisationCreateForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields["name"].widget.attrs["class"] = "form-control" - self.fields["submode"].widget.attrs["class"] = "form-control" - self.fields["oes"].widget.attrs["class"] = "form-check-input" - self.fields["active"].widget.attrs["class"] = "form-check-input" - self.fields["designation_type"].widget.attrs["class"] = "form-control" - self.fields["registered_company_name"].widget.attrs["class"] = "form-control" - self.fields["registered_company_number"].widget.attrs["class"] = "form-control" + cancel_redirect = reverse("organisations:list") + self.helper = FormHelper(self) + self.helper.layout = Layout( + Fieldset( + "", + Field("name", css_class="form-control-lg"), + "submode", + "oes", + "designation_type", + "registered_company_name", + "registered_company_number", + "updated_by", + "comments", + "active" + ), + ButtonHolder( + Submit("submit", "Submit", css_class="btn-primary"), + Button("cancel", "Cancel", onclick=f"location.href='{cancel_redirect}';", css_class="btn-danger") + ) + ) class Meta: model = Organisation fields = ["name", "submode", "oes", "designation_type", "registered_company_name", "registered_company_number", "updated_by", "comments", "active"] - # This doesn't have any effect when using the form wizard labels = { "oes": "OES" } @@ -31,7 +43,6 @@ class OrganisationCreateForm(forms.ModelForm): "updated_by": "Name of staff member/inspector creating this record", "active": "Is this company an active participant in the NIS compliance regime?", "designation_type": "This is probably defined in the Reguation", - "registered_company_name": "Probably different from the Organisation name" } @@ -42,7 +53,7 @@ class AddressCreateForm(forms.ModelForm): 'country', 'other_details') def __init__(self, *args, **kwargs): - # self.org = kwargs.pop("org") + self.org = kwargs.pop("org") super().__init__(*args, **kwargs) def save(self): |