aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack
diff options
context:
space:
mode:
Diffstat (limited to 'ctrack')
-rw-r--r--ctrack/organisations/forms.py4
-rw-r--r--ctrack/organisations/templates/organisations/org_create_wizard_form.html44
-rw-r--r--ctrack/organisations/templates/organisations/organisation_create.html3
-rw-r--r--ctrack/organisations/urls.py5
-rw-r--r--ctrack/organisations/views.py18
5 files changed, 70 insertions, 4 deletions
diff --git a/ctrack/organisations/forms.py b/ctrack/organisations/forms.py
index d4baf64..ab92e64 100644
--- a/ctrack/organisations/forms.py
+++ b/ctrack/organisations/forms.py
@@ -14,7 +14,7 @@ class OrganisationCreateForm(forms.ModelForm):
self.helper.layout = Layout(
Fieldset(
"",
- Field("name", css_class="form-control-lg"),
+ Field("name", css_class="form-control"),
"submode",
"oes",
"designation_type",
@@ -53,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):
diff --git a/ctrack/organisations/templates/organisations/org_create_wizard_form.html b/ctrack/organisations/templates/organisations/org_create_wizard_form.html
new file mode 100644
index 0000000..9305d1b
--- /dev/null
+++ b/ctrack/organisations/templates/organisations/org_create_wizard_form.html
@@ -0,0 +1,44 @@
+{% extends "base.html" %}
+
+{% block head %}
+ {{ wizard.form.media }}
+{% endblock %}
+
+{% block title %}
+ Create a new Organisation
+{% endblock title %}
+
+{% block content %}
+
+ <div class="container mt-3">
+ <div class="row">
+ <div class="col-md-12 pl-0 my-2">
+ <h4>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</h4>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-md-8 pt-2 border bg-light">
+ <form action="" method="post">
+ {% csrf_token %}
+ {{ wizard.management_form }}
+ {% if wizard.form.forms %}
+ {{ wizard.form.management_form }}
+ {% for form in wizard.form.forms %}
+ {{ form }}
+ {% endfor %}
+ {% else %}
+ {{ wizard.form }}
+ {% endif %}
+ {% if wizard.steps.prev %}
+ <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">First Step</button>
+ <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">Previous Step</button>
+ {% endif %}
+ <input type="submit" value="Submit"/>
+ </form>
+ </div>
+ </div>
+ </div>
+
+
+
+{% endblock %}
diff --git a/ctrack/organisations/templates/organisations/organisation_create.html b/ctrack/organisations/templates/organisations/organisation_create.html
index 4ee2801..035e06a 100644
--- a/ctrack/organisations/templates/organisations/organisation_create.html
+++ b/ctrack/organisations/templates/organisations/organisation_create.html
@@ -1,5 +1,6 @@
{% extends "base.html" %}
+
{% block title %}
Create a new Organisation
{% endblock title %}
@@ -10,7 +11,7 @@
<div class="container mt-3">
<div class="row">
<div class="col-md-12 pl-0 my-2">
- <h4>Create a new Organisation</h4>
+ <h4>Create a new Organisation (Step 1 of 2)</h4>
</div>
</div>
<div class="row">
diff --git a/ctrack/organisations/urls.py b/ctrack/organisations/urls.py
index 8a23cd2..1ddef8f 100644
--- a/ctrack/organisations/urls.py
+++ b/ctrack/organisations/urls.py
@@ -1,11 +1,14 @@
from django.urls import path
-from ctrack.organisations.views import OrganisationDetailView, OrganisationListView, OrganisationCreate
+from ctrack.organisations.forms import OrganisationCreateForm, AddressCreateForm
+from ctrack.organisations.views import OrganisationDetailView, OrganisationListView, OrganisationCreate, \
+ OrganisationCreateWizard
app_name = "organisations"
urlpatterns = [
path("<slug:slug>/", view=OrganisationDetailView.as_view(), name="detail"),
+ path("add-wizard", view=OrganisationCreateWizard.as_view([OrganisationCreateForm, AddressCreateForm])),
path("", view=OrganisationListView.as_view(), name="list"),
path("create", view=OrganisationCreate.as_view(), name="create")
]
diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py
index 74b290e..e90a588 100644
--- a/ctrack/organisations/views.py
+++ b/ctrack/organisations/views.py
@@ -2,12 +2,30 @@ from typing import Any
from typing import Dict
from django.contrib.auth.mixins import LoginRequiredMixin
+from django.http import HttpResponseRedirect
+from django.urls import reverse
from django.views.generic import DetailView, ListView, CreateView
+from formtools.wizard.views import SessionWizardView
from .forms import OrganisationCreateForm
from .models import Organisation
+def save_organisation_to_database(form_list):
+ """
+ When we have a multi-part wizard form data back, we save it to the database here!
+ """
+ pass
+
+
+class OrganisationCreateWizard(LoginRequiredMixin, SessionWizardView):
+ template_name = "organisations/org_create_wizard_form.html"
+
+ def done(self, form_list, **kwargs):
+ save_organisation_to_database(form_list)
+ return HttpResponseRedirect(reverse("organisations:list"))
+
+
class OrganisationCreate(LoginRequiredMixin, CreateView):
form_class = OrganisationCreateForm
model = Organisation