diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-21 14:49:36 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-21 14:49:36 +0100 |
commit | d4e6e7b3c8f10c6671cecea2c2ca42578678eb4a (patch) | |
tree | 5d50ce13ae5f391ac12a0ae37e39399649d91951 /ctrack | |
parent | 6d2cd94729a20904d5970b895e686af40353868e (diff) |
can now add caf single date events to caf detail page
Diffstat (limited to '')
-rw-r--r-- | ctrack/caf/templates/caf/caf_detail.html | 10 | ||||
-rw-r--r-- | ctrack/register/forms.py | 2 | ||||
-rw-r--r-- | ctrack/register/tests/test_forms.py | 4 | ||||
-rw-r--r-- | ctrack/register/tests/test_views.py | 1 | ||||
-rw-r--r-- | ctrack/register/views.py | 4 |
5 files changed, 13 insertions, 8 deletions
diff --git a/ctrack/caf/templates/caf/caf_detail.html b/ctrack/caf/templates/caf/caf_detail.html index 3a73beb..166ced8 100644 --- a/ctrack/caf/templates/caf/caf_detail.html +++ b/ctrack/caf/templates/caf/caf_detail.html @@ -128,19 +128,19 @@ <thead> <tr class="d-flex"> <th class="col-1">Date</th> - <th class="col-2">Event</th> + <th class="col-3">Event</th> <th class="col-2">Inspector</th> - <th class="col-3">Description</th> + <th class="col-2">Description</th> <th class="col-4">Comments</th> </tr> </thead> <tbody> {% for event in all_events %} <tr class="d-flex"> - <td class="col-1">{{ event.date }}</td> - <td class="col-2">{{ event.type_descriptor }}</td> + <td class="col-1">{{ event.date|date:"j/n/y" }}</td> + <td class="col-3">{{ event.type_descriptor }}</td> <td class="col-2">{{ event.user.name }}</td> - <td class="col-3">{{ event.short_description }}</td> + <td class="col-2">{{ event.short_description }}</td> <td class="col-4">{{ event.comments }}</td> </tr> {% endfor %} diff --git a/ctrack/register/forms.py b/ctrack/register/forms.py index 512ae9d..cca4cb9 100644 --- a/ctrack/register/forms.py +++ b/ctrack/register/forms.py @@ -107,7 +107,6 @@ class CAFSingleDateEventForm(forms.ModelForm): fields = [ "type_descriptor", "date", - "related_caf", "short_description", "document_link", "comments", @@ -121,6 +120,7 @@ class CAFSingleDateEventForm(forms.ModelForm): def save(self, **kwargs): form = super().save(commit=False) form.user = self.user + form.related_caf = CAF.objects.get(id=self.caf_id) form.save() return form diff --git a/ctrack/register/tests/test_forms.py b/ctrack/register/tests/test_forms.py index 1ba1cf9..4a9e818 100644 --- a/ctrack/register/tests/test_forms.py +++ b/ctrack/register/tests/test_forms.py @@ -137,7 +137,7 @@ def test_create_note(user, org_with_people): "CAF_VALIDATION_RECORD_EMAILED_TO_OES", ], ) -def test_allowable_caf_single_date_event_forms(allowed_type, user, caf): +def test_caf_single_date_event_forms(allowed_type, user, caf): form = CAFSingleDateEventForm( { "type_descriptor": allowed_type, @@ -146,7 +146,7 @@ def test_allowable_caf_single_date_event_forms(allowed_type, user, caf): "date": "2010-07-01", "comments": "Meaningless comments", }, - user=user, + user=user, caf_id=caf.id ) assert form.is_valid() diff --git a/ctrack/register/tests/test_views.py b/ctrack/register/tests/test_views.py index 0876332..4e8152c 100644 --- a/ctrack/register/tests/test_views.py +++ b/ctrack/register/tests/test_views.py @@ -203,3 +203,4 @@ class TestSingleDateCAFEventViews: f"Register a single date event for {caf.version} ({caf.organisation.name})", html, ) + assert "Related caf" not in html diff --git a/ctrack/register/views.py b/ctrack/register/views.py index 49e40d8..c8fe1c5 100644 --- a/ctrack/register/views.py +++ b/ctrack/register/views.py @@ -166,6 +166,10 @@ class CAFCreateSingleDateEventView(FormView): kwargs["caf_id"] = self.kwargs.get("caf_id") return kwargs + def form_valid(self, form): + form.save() + return super().form_valid(form) + def get_success_url(self): self.success_url = reverse_lazy("caf:detail", args=[self.kwargs.get("caf_id")]) return super().get_success_url() |