From d187f341b396d6bca355123714c2eb58cee922f2 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Thu, 12 Apr 2012 20:11:05 +0200 Subject: [PATCH] DeleteView in utils.views --- .../application/templates/application/view.html | 2 +- .../assignment/templates/assignment/poll_view.html | 4 ++-- openslides/utils/views.py | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/openslides/application/templates/application/view.html b/openslides/application/templates/application/view.html index cad41af32..b4f1d7ce5 100644 --- a/openslides/application/templates/application/view.html +++ b/openslides/application/templates/application/view.html @@ -81,7 +81,7 @@ {{ option.contained }}
{{ poll.print_votesinvalid }}
- {{ poll.poll_votescast }} + {{ poll.print_votescast }}
{% endwith %} {% if perms.application.can_manage_application %} diff --git a/openslides/assignment/templates/assignment/poll_view.html b/openslides/assignment/templates/assignment/poll_view.html index 62e4b1ea3..1286525f2 100644 --- a/openslides/assignment/templates/assignment/poll_view.html +++ b/openslides/assignment/templates/assignment/poll_view.html @@ -11,8 +11,8 @@

{% trans "Short description" %}: {{ poll.description }}

-1 := {% trans 'majority' %}, -2 := {% trans 'undocumented' %} -
{% csrf_token %} - + {% csrf_token %} +
{% for value in poll.get_vote_values %} diff --git a/openslides/utils/views.py b/openslides/utils/views.py index 942e7b11e..5bac17f7d 100644 --- a/openslides/utils/views.py +++ b/openslides/utils/views.py @@ -32,6 +32,7 @@ from django.views.generic import ( ) from django.views.generic.detail import SingleObjectMixin from django.utils.importlib import import_module +from django.core.context_processors import csrf import settings from utils import render_to_forbitten @@ -166,6 +167,19 @@ class DeleteView(RedirectView, SingleObjectMixin): self.object = self.get_object() self.confirm_form(request, self.object) + def pre_post_redirect(self, request, *args, **kwargs): + self.object = self.get_object() + self.object.delete() + messages.success(request, _("Item %s was successfully deleted.") % self.object) + + def confirm_form(self, request, object, name=None): + if name is None: + name = object + self.gen_confirm_form(request, _('Do you really want to delete %s?') % name, object.get_absolute_url('delete')) + + def gen_confirm_form(self, request, message, url): + messages.warning(request, '%s' % (message, url, csrf(request)['csrf_token'], _("Yes"), _("No"))) + class PDFView(PermissionMixin, View): filename = 'No_Name'
Option