aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/organisations/forms.py
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2020-04-21 22:16:00 +0100
committerMatthew Lemon <matt@matthewlemon.com>2020-04-21 22:16:00 +0100
commitb1d0fa9854e91572339056ea8d38a839a6e8fd43 (patch)
tree5b11cb55cf1c62616d4180bb17c7be777eed5244 /ctrack/organisations/forms.py
parent4abbf4b838513b9157b84e080d90d40292eee997 (diff)
started work on the create organisation page
Diffstat (limited to '')
-rw-r--r--ctrack/organisations/forms.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/ctrack/organisations/forms.py b/ctrack/organisations/forms.py
new file mode 100644
index 0000000..59782e0
--- /dev/null
+++ b/ctrack/organisations/forms.py
@@ -0,0 +1,37 @@
+from crispy_forms.helper import FormHelper
+from crispy_forms.layout import Layout, Fieldset, ButtonHolder, Submit, Button, Hidden
+from django import forms
+from django.urls import reverse
+
+from ctrack.organisations.models import Organisation
+
+
+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(
+ f"Create a new Organisation",
+ "name",
+ "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"]