Changed utils.views.DeleteView
This commit is contained in:
parent
da7a7a9d68
commit
b6256b73e0
@ -287,10 +287,25 @@ class CreateView(PermissionMixin, UrlMixin, ExtraContextMixin,
|
|||||||
|
|
||||||
|
|
||||||
class DeleteView(SingleObjectMixin, QuestionMixin, RedirectView):
|
class DeleteView(SingleObjectMixin, QuestionMixin, RedirectView):
|
||||||
|
question_url_name = None
|
||||||
|
success_url_name = None
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
return super(DeleteView, self).get(request, *args, **kwargs)
|
return super(DeleteView, self).get(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def get_redirect_url(self, **kwargs):
|
||||||
|
if self.request.method == 'GET':
|
||||||
|
if self.question_url_name is not None:
|
||||||
|
return reverse(self.question_url_name, args=self.get_url_name_args())
|
||||||
|
else:
|
||||||
|
return self.object.get_absolute_url()
|
||||||
|
else:
|
||||||
|
return reverse(self.success_url_name, args=self.get_url_name_args())
|
||||||
|
|
||||||
|
def get_url_name_args(self):
|
||||||
|
return [self.poll.motion.pk]
|
||||||
|
|
||||||
def get_question(self):
|
def get_question(self):
|
||||||
return _('Do you really want to delete %s?') % html_strong(self.object)
|
return _('Do you really want to delete %s?') % html_strong(self.object)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user