diff options
author | MR Lemon <matt@matthewlemon> | 2020-05-05 15:27:59 +0100 |
---|---|---|
committer | MR Lemon <matt@matthewlemon> | 2020-05-05 15:27:59 +0100 |
commit | f74421c9a8982a692f190b0f9b0d3338b6f32fa8 (patch) | |
tree | 16994894ceed0ed60784204cfc5a59860889f92a /ctrack | |
parent | 73a7322d6591ca76806e6e6f0dc7a4b2b1683a0c (diff) |
organisation bit of the form looking better now after manually formatting the html
Diffstat (limited to 'ctrack')
-rw-r--r-- | ctrack/organisations/forms.py | 29 | ||||
-rw-r--r-- | ctrack/organisations/templates/organisations/org_create_formset.html | 66 | ||||
-rw-r--r-- | ctrack/organisations/views.py | 1 |
3 files changed, 72 insertions, 24 deletions
diff --git a/ctrack/organisations/forms.py b/ctrack/organisations/forms.py index 2fe5033..30a24c5 100644 --- a/ctrack/organisations/forms.py +++ b/ctrack/organisations/forms.py @@ -1,8 +1,7 @@ from crispy_forms.helper import FormHelper -from crispy_forms.layout import Layout, Fieldset, Field, ButtonHolder, Submit +from crispy_forms.layout import Layout, Submit from django import forms from django.forms import inlineformset_factory -from django.urls import reverse from ctrack.organisations.models import Organisation, Address @@ -10,21 +9,14 @@ 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-lg"), - "submode", - "oes", - "designation_type", - "registered_company_name", - "registered_company_number", - "comments", - "active" - ), - ) + self.fields["name"].widget.attrs["class"] = "form-control form-control-lg" + self.fields["submode"].widget.attrs["class"] = "form-control" + self.fields["oes"].widget.attrs["class"] = "form-check-input" + self.fields["oes"].widget.attrs["type"] = "checkbox" + 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" + self.fields["comments"].widget.attrs["class"] = "form-control" class Meta: model = Organisation @@ -35,9 +27,10 @@ class OrganisationCreateForm(forms.ModelForm): "oes": "OES" } help_texts = { + "name": "Name of the organisation", "submode": "e.g. Rail Maintenance, TOC, etc...", "active": "Is this company an active participant in the NIS compliance regime?", - "designation_type": "This is probably defined in the Reguation", + "designation_type": "This is probably defined in the Regulation", } diff --git a/ctrack/organisations/templates/organisations/org_create_formset.html b/ctrack/organisations/templates/organisations/org_create_formset.html index 393b94e..251e5da 100644 --- a/ctrack/organisations/templates/organisations/org_create_formset.html +++ b/ctrack/organisations/templates/organisations/org_create_formset.html @@ -9,15 +9,71 @@ {% block content %} <div class="container"> + <h4>Create a new organisation</h4> <div class="row"> - <div class="col-md-12"> + <div class="col-md-8"> <form method="post" action=""> - {% csrf_token %} - {{ form }} - {% crispy addresses helper %} - </form> + {# this is the parent form - in this case the organisation form #} + <div class="form-group"> + {{ form.non_field_errors }} + <label for="{{ form.name.id_for_label }}">Name:</label> + {{ form.name }} + <small class="form-text text-muted">{{ form.name.help_text }}</small> + </div> + + <div class="form-check"> + {{ form.non_field_errors }} + {{ form.oes }} + <label class="form-check-label" for="{{ form.oes.id_for_label }}">OES</label> + <small class="form-text text-muted">{{ form.oes.help_text }}</small> + </div> + + + <div class="form-group"> + {{ form.non_field_errors }} + <label for="{{ form.submode.id_for_label }}">Sub mode:</label> + {{ form.submode }} + <small class="form-text text-muted">{{ form.submode.help_text }}</small> + </div> + + <div class="form-group"> + {{ form.non_field_errors }} + <label for="{{ form.designation_type.id_for_label }}">Designation Type:</label> + {{ form.designation_type }} + <small class="form-text text-muted">{{ form.designation_type.help_text }}</small> + </div> + + <div class="form-group"> + {{ form.non_field_errors }} + <label for="{{ form.registered_company_name.id_for_label }}">Registered Company Name:</label> + {{ form.registered_company_name }} + <small class="form-text text-muted">{{ form.registered_company_name.help_text }}</small> + </div> + + <div class="form-group"> + {{ form.non_field_errors }} + <label for="{{ form.registered_company_number.id_for_label }}">Registered Company Number:</label> + {{ form.registered_company_number }} + <small class="form-text text-muted">{{ form.registered_company_number.help_text }}</small> + </div> + + <div class="form-group"> + {{ form.non_field_errors }} + <label for="{{ form.comments.id_for_label }}">Comments:</label> + {{ form.comments }} + <small class="form-text text-muted">{{ form.comments.help_text }}</small> + </div> + + </div> + </div> + <h5>Add address:</h5> + <div class="row"> + <div class="col-md-8"> + {% crispy addresses helper %} </div> </div> + {# This is the address inlineformset#} + </form> </div> {% endblock %} diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py index 925ac77..6578bdc 100644 --- a/ctrack/organisations/views.py +++ b/ctrack/organisations/views.py @@ -1,7 +1,6 @@ from typing import Any from typing import Dict -from crispy_forms.layout import Submit from django.contrib.auth.mixins import LoginRequiredMixin from django.db import transaction from django.urls import reverse_lazy |