From deaa85227e47dd70301f88caca87edb0ad3f8adf Mon Sep 17 00:00:00 2001 From: MR Lemon Date: Fri, 24 Apr 2020 20:33:40 +0100 Subject: made create forms more consistent --- ctrack/caf/forms.py | 14 +++++++------- ctrack/caf/migrations/0003_auto_20200424_1924.py | 18 ++++++++++++++++++ ctrack/caf/models.py | 2 +- .../caf/applicable_system_create_from_caf.html | 21 ++++++++++++++++++--- .../caf/applicable_system_create_from_org.html | 22 ++++++++++++++++++++-- ctrack/caf/views.py | 3 ++- 6 files changed, 66 insertions(+), 14 deletions(-) create mode 100644 ctrack/caf/migrations/0003_auto_20200424_1924.py diff --git a/ctrack/caf/forms.py b/ctrack/caf/forms.py index 3fe90a0..a21488a 100644 --- a/ctrack/caf/forms.py +++ b/ctrack/caf/forms.py @@ -34,9 +34,9 @@ class ApplicableSystemCreateFromCafForm(forms.Form): self.helper = FormHelper(self) self.helper.layout = Layout( Fieldset( - f"Create a new system for {caf}", - Field("name", css_class="form-control form-control-sm"), - Field("description", cass_class="form-control form-control-sm"), + "", + Field("name", css_class="form-control-lg"), + "description", Hidden("caf", caf_id), Hidden("organisation", org_id), ), @@ -61,11 +61,11 @@ class ApplicableSystemCreateFromOrgForm(forms.Form): self.helper = FormHelper(self) self.helper.layout = Layout( Fieldset( - f"Create a new system for {org_name}", - Field("name", css_class="form-control form-control-sm"), - Field("description", css_class="form-control form-control-sm"), + "", + Field("name", css_class="form-control-lg"), + "description", Hidden("organisation", org_id), - Field("caf", css_class="form-control form-control-sm") + "caf", ), ButtonHolder( Submit("submit", "Submit", css_class="btn-primary"), diff --git a/ctrack/caf/migrations/0003_auto_20200424_1924.py b/ctrack/caf/migrations/0003_auto_20200424_1924.py new file mode 100644 index 0000000..34613c6 --- /dev/null +++ b/ctrack/caf/migrations/0003_auto_20200424_1924.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.9 on 2020-04-24 19:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('caf', '0002_auto_20200403_1407'), + ] + + operations = [ + migrations.AlterField( + model_name='applicablesystem', + name='description', + field=models.TextField(blank=True, max_length=1000, null=True), + ), + ] diff --git a/ctrack/caf/models.py b/ctrack/caf/models.py index 0151d4b..1754e61 100644 --- a/ctrack/caf/models.py +++ b/ctrack/caf/models.py @@ -48,7 +48,7 @@ class ApplicableSystem(models.Model): return Organisation.objects.get_or_create(name="DELETED ORGANISATION")[0] name = models.CharField(max_length=256) - description = models.TextField(max_length=1000) + description = models.TextField(max_length=1000, blank=True, null=True) organisation = models.ForeignKey( Organisation, on_delete=models.SET(get_sentinel_org) ) diff --git a/ctrack/caf/templates/caf/applicable_system_create_from_caf.html b/ctrack/caf/templates/caf/applicable_system_create_from_caf.html index fffb5f4..0c39fb6 100644 --- a/ctrack/caf/templates/caf/applicable_system_create_from_caf.html +++ b/ctrack/caf/templates/caf/applicable_system_create_from_caf.html @@ -1,16 +1,31 @@ {% extends "base.html" %} + {% block title %} - Create a new Applicable System to an existing CAF + Add a new system to {{ caf }} {% endblock title %} {% load crispy_forms_tags %} {% block content %} -
+
-
+
+

Add a new system to {{ caf }}

+
+
+
+
{% crispy form %}
+
+
+
+
Help on System
+

Here you can add some supplementary text if you like.

+ Go somewhere +
+
+
{% endblock content %} diff --git a/ctrack/caf/templates/caf/applicable_system_create_from_org.html b/ctrack/caf/templates/caf/applicable_system_create_from_org.html index a655f3e..0d0fcef 100644 --- a/ctrack/caf/templates/caf/applicable_system_create_from_org.html +++ b/ctrack/caf/templates/caf/applicable_system_create_from_org.html @@ -1,13 +1,31 @@ {% extends "base.html" %} +{% block title %} + Add a new system for {{ organisation }} +{% endblock title %} + {% load crispy_forms_tags %} {% block content %} -
+
-
+
+

Add a new system for {{ organisation }}

+
+
+
+
{% crispy form %}
+
+
+
+
Help on Adding a new System
+

Here you can add some supplementary text if you like.

+ Go somewhere +
+
+
{% endblock content %} diff --git a/ctrack/caf/views.py b/ctrack/caf/views.py index 5308421..0cee746 100644 --- a/ctrack/caf/views.py +++ b/ctrack/caf/views.py @@ -60,6 +60,7 @@ class ApplicableSystemDetail(LoginRequiredMixin, DetailView): @login_required def applicable_system_create_from_caf(request, caf_id): org_id = CAF.objects.get(pk=caf_id).organisation().id + caf = CAF.objects.get(id=caf_id) if request.method=="POST": form = ApplicableSystemCreateFromCafForm(request.POST, caf_id=caf_id, org_id=org_id) if form.is_valid(): @@ -73,7 +74,7 @@ def applicable_system_create_from_caf(request, caf_id): else: form = ApplicableSystemCreateFromCafForm(caf_id=caf_id, org_id=org_id) - return render(request, "caf/applicable_system_create_from_caf.html", {"form": form}) + return render(request, "caf/applicable_system_create_from_caf.html", {"form": form, "caf": caf}) class ApplicableSystemCreateFromOrg(LoginRequiredMixin, FormView): -- cgit v1.2.3