aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/register/views.py
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-09-29 16:21:13 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-09-29 16:21:13 +0100
commit1e2993a8e092bf4b725ebc23d6e79fe60a8b8978 (patch)
tree7f10d8d47d6abcac3441f5d2c653e2d74e49fad1 /ctrack/register/views.py
parent7ad343a875a8dbd667824685065b905b14a49870 (diff)
Delete button now works for Engagement Event
Diffstat (limited to '')
-rw-r--r--ctrack/register/views.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/ctrack/register/views.py b/ctrack/register/views.py
index 3daabd7..32faf4d 100644
--- a/ctrack/register/views.py
+++ b/ctrack/register/views.py
@@ -2,23 +2,32 @@ from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import HttpResponseRedirect
from django.urls import reverse, reverse_lazy
-from django.views.generic import FormView
+from django.views.generic import FormView, DeleteView
from ctrack.organisations.models import Organisation
from ctrack.register.forms import EngagementEventCreateForm
+from ctrack.register.models import EngagementEvent
+
+
+class EngagementEventDelete(DeleteView):
+ model = EngagementEvent
+
+ def get_success_url(self):
+ return reverse_lazy("organisations:detail", args=[self.kwargs["slug"]])
+
class EngagementEventCreate(LoginRequiredMixin, FormView):
fields = "__all__"
form_class = EngagementEventCreateForm
template_name = "register/engagementevent_form.html"
- success_url = reverse_lazy("organisations:list")
+ # success_url = reverse_lazy("organisations:list")
def form_valid(self, form):
ee = form.save(commit=False)
ee.user = self.request.user
form.save()
- return HttpResponseRedirect(reverse("organisations:list"))
+ return HttpResponseRedirect(self.get_success_url())
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
@@ -30,3 +39,6 @@ class EngagementEventCreate(LoginRequiredMixin, FormView):
context = super().get_context_data()
context["org"] = Organisation.objects.get(slug=self.kwargs["slug"])
return context
+
+ def get_success_url(self):
+ return reverse_lazy("organisations:detail", args=[self.kwargs["slug"]])