From ae8641bcad9e49f3c85fce46b56d82bee847493b Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sat, 5 Jan 2013 01:48:03 +0100 Subject: [PATCH] Raise an error if an CreateView does not define a apply_url --- openslides/utils/views.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openslides/utils/views.py b/openslides/utils/views.py index fbc742bf4..33bdafc32 100644 --- a/openslides/utils/views.py +++ b/openslides/utils/views.py @@ -241,6 +241,8 @@ class UpdateView(PermissionMixin, _UpdateView): class CreateView(PermissionMixin, _CreateView): + apply_url = None + def get_success_url(self): messages.success(self.request, self.get_success_message()) if 'apply' in self.request.POST: @@ -254,7 +256,12 @@ class CreateView(PermissionMixin, _CreateView): return context def get_apply_url(self): - return self.apply_url + if self apply_url: + return self.apply_url + else: + raise ImproperlyConfigured( + "No URL to redirect to. Provide a apply_url.") + def form_invalid(self, form): messages.error(self.request, _('Please check the form for errors.'))