diff options
author | MR Lemon <matt@matthewlemon> | 2020-04-17 16:03:51 +0100 |
---|---|---|
committer | MR Lemon <matt@matthewlemon> | 2020-04-17 16:03:51 +0100 |
commit | 51149b561a44e5ecfbca90dfb9989985ccf2c122 (patch) | |
tree | fd39a5d1768ed79a9b3a3419dc63edf2522e5e59 | |
parent | a4be1627b2705bba96d80204043876a3abec6a24 (diff) |
Adding a form for creating ApplicableSystem objects
-rw-r--r-- | config/settings/local.py | 2 | ||||
-rw-r--r-- | ctrack/caf/forms.py | 23 | ||||
-rw-r--r-- | ctrack/caf/templates/caf/applicablesystem_create.html | 14 | ||||
-rw-r--r-- | ctrack/caf/urls.py | 6 | ||||
-rw-r--r-- | ctrack/caf/views.py | 9 | ||||
-rw-r--r-- | ctrack/static/css/project.css | 5 | ||||
-rw-r--r-- | ctrack/static/css/project.css.map | 2 | ||||
-rw-r--r-- | ctrack/static/sass/project.scss | 10 |
8 files changed, 57 insertions, 14 deletions
diff --git a/config/settings/local.py b/config/settings/local.py index 311fb77..34fc189 100644 --- a/config/settings/local.py +++ b/config/settings/local.py @@ -23,6 +23,8 @@ CACHES = { } } +CRISPY_FAIL_SILENTLY = not DEBUG + # EMAIL # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#email-backend diff --git a/ctrack/caf/forms.py b/ctrack/caf/forms.py index fac3049..5903a2c 100644 --- a/ctrack/caf/forms.py +++ b/ctrack/caf/forms.py @@ -18,3 +18,26 @@ from django.forms.models import ModelMultipleChoiceField CAFCreateInlineFormset = inlineformset_factory( CAF, ApplicableSystem, fields=("name", "organisation"), extra=2) + + +class ApplicableSystemCreateForm(forms.ModelForm): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.helper = FormHelper(self) + self.helper.layout = Layout( + Fieldset( + "Create a new System", + "name", + "description", + "organisation", + "caf", + ), + ButtonHolder( + Submit("submit", "Submit", css_class="btn-primary") + ) + ) + + class Meta: + model = ApplicableSystem + fields = ["name", "description", "organisation", "caf"] diff --git a/ctrack/caf/templates/caf/applicablesystem_create.html b/ctrack/caf/templates/caf/applicablesystem_create.html new file mode 100644 index 0000000..5d5f4d9 --- /dev/null +++ b/ctrack/caf/templates/caf/applicablesystem_create.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} +{% load crispy_forms_filters %} + +{% load crispy_forms_tags %} + +{% block content %} + <div class="container"> + <div class="row"> + <div class="col-lg-6"> + {% crispy form %} + </div> + </div> + </div> +{% endblock content %} diff --git a/ctrack/caf/urls.py b/ctrack/caf/urls.py index 943fede..72a1de5 100644 --- a/ctrack/caf/urls.py +++ b/ctrack/caf/urls.py @@ -1,7 +1,8 @@ from django.urls import path from django.views.decorators.cache import cache_page -from ctrack.caf.views import ListCAF, ListApplicableSystem, caf_detail_view, ApplicableSystemDetail +from ctrack.caf.views import ListCAF, ListApplicableSystem, caf_detail_view, ApplicableSystemDetail, \ + ApplicableSystemCreate app_name = "caf" @@ -9,5 +10,6 @@ urlpatterns = [ path("", view=ListCAF.as_view(), name="caf_list"), path("applicablesystems", cache_page(60 * 60)(ListApplicableSystem.as_view()), name="es_list"), path("applicablesystems/<int:pk>", ApplicableSystemDetail.as_view(), name="ass_detail"), - path("<int:pk>", caf_detail_view, name="detail") + path("applicablesystem/", ApplicableSystemCreate.as_view(), name="create"), + path("<int:pk>", caf_detail_view, name="detail") ] diff --git a/ctrack/caf/views.py b/ctrack/caf/views.py index 4bcfe61..9a5cb64 100644 --- a/ctrack/caf/views.py +++ b/ctrack/caf/views.py @@ -1,8 +1,9 @@ from django.contrib.auth.mixins import LoginRequiredMixin from django.shortcuts import render -from django.views.generic import ListView, DetailView +from django.views.generic import ListView, DetailView, CreateView from ctrack.assessments.models import CAFAssessmentOutcomeScore +from ctrack.caf.forms import ApplicableSystemCreateForm from ctrack.caf.models import ApplicableSystem, CAF @@ -49,3 +50,9 @@ class ListApplicableSystem(LoginRequiredMixin, ListView): class ApplicableSystemDetail(LoginRequiredMixin, DetailView): model = ApplicableSystem template_name = "caf/applicablesystem_detail.html" + + +class ApplicableSystemCreate(LoginRequiredMixin, CreateView): + form_class = ApplicableSystemCreateForm + model = ApplicableSystem + template_name = "caf/applicablesystem_create.html" diff --git a/ctrack/static/css/project.css b/ctrack/static/css/project.css index fe3d2d4..ea06812 100644 --- a/ctrack/static/css/project.css +++ b/ctrack/static/css/project.css @@ -40,11 +40,6 @@ background-color: red; color: white; } -.textinput { - background-color: lightgoldenrodyellow; - box-shadow: 2px 10px 15px lightgray; - height: 49px; } - #_title { color: orangered; } diff --git a/ctrack/static/css/project.css.map b/ctrack/static/css/project.css.map index a591f8a..eb339b3 100644 --- a/ctrack/static/css/project.css.map +++ b/ctrack/static/css/project.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AA2BA,YAAa;EACX,gBAAgB,EAhBV,IAAI;EAiBV,YAAY,EAhBD,OAAO;EAiBlB,KAAK,EAhBC,IAAI;;AAmBZ,YAAa;EACX,gBAAgB,EAnBX,OAAO;EAoBZ,YAAY,EAnBF,OAAO;EAoBjB,KAAK,EAnBD,OAAO;;AAsBb,SAAU;EACR,gBAAgB,EAAE,KAAK;;AAGzB,UAAW;EACT,gBAAgB,EAAE,GAAG;EACrB,YAAY,EAAE,MAAM;;AAStB,OAAQ;EACN,MAAM,EAAE,sBAAsB;EAC9B,aAAa,EAAE,IAAI;EACnB,UAAU,EAAE,uBAAuB;;AAGrC,eAAgB;EACd,UAAU,EAAE,MAAM;;AAGpB,YAAa;EACX,SAAS,EAAE,OAAO;EAClB,WAAW,EAAE,IAAI;EACjB,UAAU,EAAE,IAAI;;AAIlB,wBAAyB;EACvB,gBAAgB,EAAE,OAAgB;EAClC,KAAK,EAAE,KAAK;;AAGd,cAAe;EACb,gBAAgB,EAAE,KAAK;EACvB,KAAK,EAAE,KAAK;;AAGd,kBAAmB;EACjB,gBAAgB,EAAE,GAAG;EACrB,KAAK,EAAE,KAAK;;AAGd,UAAW;EACT,gBAAgB,EAAE,oBAAoB;EACtC,UAAU,EAAE,uBAAuB;EACnC,MAAM,EAvEO,IAAI;;AA0EnB,OAAQ;EACN,KAAK,EAAE,SAAS", +"mappings": "AA2BA,YAAa;EACX,gBAAgB,EAhBV,IAAI;EAiBV,YAAY,EAhBD,OAAO;EAiBlB,KAAK,EAhBC,IAAI;;AAmBZ,YAAa;EACX,gBAAgB,EAnBX,OAAO;EAoBZ,YAAY,EAnBF,OAAO;EAoBjB,KAAK,EAnBD,OAAO;;AAsBb,SAAU;EACR,gBAAgB,EAAE,KAAK;;AAGzB,UAAW;EACT,gBAAgB,EAAE,GAAG;EACrB,YAAY,EAAE,MAAM;;AAStB,OAAQ;EACN,MAAM,EAAE,sBAAsB;EAC9B,aAAa,EAAE,IAAI;EACnB,UAAU,EAAE,uBAAuB;;AAGrC,eAAgB;EACd,UAAU,EAAE,MAAM;;AAGpB,YAAa;EACX,SAAS,EAAE,OAAO;EAClB,WAAW,EAAE,IAAI;EACjB,UAAU,EAAE,IAAI;;AAIlB,wBAAyB;EACvB,gBAAgB,EAAE,OAAgB;EAClC,KAAK,EAAE,KAAK;;AAGd,cAAe;EACb,gBAAgB,EAAE,KAAK;EACvB,KAAK,EAAE,KAAK;;AAGd,kBAAmB;EACjB,gBAAgB,EAAE,GAAG;EACrB,KAAK,EAAE,KAAK;;AASd,OAAQ;EACN,KAAK,EAAE,SAAS", "sources": ["../sass/project.scss"], "names": [], "file": "project.css" diff --git a/ctrack/static/sass/project.scss b/ctrack/static/sass/project.scss index d02b73d..df305ef 100644 --- a/ctrack/static/sass/project.scss +++ b/ctrack/static/sass/project.scss @@ -84,11 +84,11 @@ $input-height: 49px; color: white; } -.textinput { - background-color: lightgoldenrodyellow; - box-shadow: 2px 10px 15px lightgray; - height: $input-height; -} +//.textinput { +// background-color: lightgoldenrodyellow; +// box-shadow: 2px 10px 15px lightgray; +// height: $input-height; +//} #_title { color: orangered; |