From 089eb10d5023e92969b72561baca32a9d730f0c6 Mon Sep 17 00:00:00 2001 From: MR Lemon Date: Fri, 1 May 2020 15:51:59 +0100 Subject: making progress with the form wizard --- config/settings/base.py | 1 + ctrack/organisations/forms.py | 26 ++++----------- .../organisations/org_create_wizard_form.html | 37 ++++++++++++++++++++-- 3 files changed, 42 insertions(+), 22 deletions(-) diff --git a/config/settings/base.py b/config/settings/base.py index fd3f502..e1d7763 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -81,6 +81,7 @@ THIRD_PARTY_APPS = [ "allauth", "allauth.account", "allauth.socialaccount", + "formtools", ] LOCAL_APPS = [ diff --git a/ctrack/organisations/forms.py b/ctrack/organisations/forms.py index ab92e64..0903649 100644 --- a/ctrack/organisations/forms.py +++ b/ctrack/organisations/forms.py @@ -9,26 +9,11 @@ from ctrack.organisations.models import Organisation, Address class OrganisationCreateForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - cancel_redirect = reverse("organisations:list") - self.helper = FormHelper(self) - self.helper.layout = Layout( - Fieldset( - "", - Field("name", css_class="form-control"), - "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") - ) - ) + 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["designation_type"].widget.attrs["class"] = "form-control" + self.fields["registered_company_name"].widget.attrs["class"] = "form-control" class Meta: model = Organisation @@ -43,6 +28,7 @@ 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" } diff --git a/ctrack/organisations/templates/organisations/org_create_wizard_form.html b/ctrack/organisations/templates/organisations/org_create_wizard_form.html index 9305d1b..8faa1a3 100644 --- a/ctrack/organisations/templates/organisations/org_create_wizard_form.html +++ b/ctrack/organisations/templates/organisations/org_create_wizard_form.html @@ -11,9 +11,14 @@ {% block content %}
+
+
+

Create a new Organisation

+
+
-

Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}

+

Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}

@@ -27,7 +32,35 @@ {{ form }} {% endfor %} {% else %} - {{ wizard.form }} +
+ + {{ wizard.form.name }} +
+
+
+
+ + {{ wizard.form.submode }} +
+
+
+
+ + {{ wizard.form.designation_type }} + {{ wizard.form.designation_type.help_text }} +
+
+
+
+ {{ wizard.form.oes }} + +
+
+ + {{ wizard.form.registered_company_name }} + {{ wizard.form.registered_company_name.help_text }} +
+{# {{ wizard.form }}#} {% endif %} {% if wizard.steps.prev %} -- cgit v1.2.3