diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-21 14:31:41 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-21 14:31:41 +0100 |
commit | 6d2cd94729a20904d5970b895e686af40353868e (patch) | |
tree | 6af2b26fc11f5a26ee6bd4019fda282e02e15e51 /ctrack/register/views.py | |
parent | 22bfb9da5bd6da1e7de4bf5545144fab97f93f8d (diff) |
adding the form for caf single date event
Diffstat (limited to '')
-rw-r--r-- | ctrack/register/views.py | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/ctrack/register/views.py b/ctrack/register/views.py index 935bbed..49e40d8 100644 --- a/ctrack/register/views.py +++ b/ctrack/register/views.py @@ -7,9 +7,9 @@ from ctrack.caf.models import CAF from ctrack.organisations.models import Organisation from ctrack.register.forms import ( CreateSimpleDateTimeEventForm, - EngagementEventCreateForm, CreateNoteEventForm, + EngagementEventCreateForm, CreateNoteEventForm, CAFSingleDateEventForm, ) -from ctrack.register.models import EngagementEvent, SingleDateTimeEvent, NoteEvent +from ctrack.register.models import EngagementEvent, SingleDateTimeEvent, NoteEvent, CAFSingleDateEvent class EngagementEventDelete(DeleteView): @@ -122,7 +122,7 @@ class SingleDateTimeEventUpdate(UpdateView): class SingleDateTimeEventCreate(FormView): - template_name = "single_datetime_event_create.html" + template_name = "register/single_datetime_event_create.html" form_class = CreateSimpleDateTimeEventForm success_url = reverse_lazy("organisations:list") @@ -153,3 +153,24 @@ class SingleDateTimeEventCreate(FormView): def form_valid(self, form): form.save() return super().form_valid(form) + + +class CAFCreateSingleDateEventView(FormView): + template_name = "register/caf_single_date_event_form.html" + form_class = CAFSingleDateEventForm + success_url = reverse_lazy("caf:detail") + + def get_form_kwargs(self): + kwargs = super().get_form_kwargs() + kwargs["user"] = self.request.user + kwargs["caf_id"] = self.kwargs.get("caf_id") + return kwargs + + def get_success_url(self): + self.success_url = reverse_lazy("caf:detail", args=[self.kwargs.get("caf_id")]) + return super().get_success_url() + + def get_context_data(self, **kwargs): + context = super().get_context_data() + context["caf"] = CAF.objects.get(id=self.kwargs.get("caf_id")) + return context |