DeleteView in utils.views
This commit is contained in:
parent
9e6aa796ab
commit
d187f341b3
@ -81,7 +81,7 @@
|
||||
<img src="/static/images/icons/voting-abstention.png" title="{% trans 'Abstention' %}"> {{ option.contained }}<br>
|
||||
<img src="/static/images/icons/voting-invalid.png" title="{% trans 'Invalid' %}"> {{ poll.print_votesinvalid }}<br>
|
||||
<div style="border-top: 1px solid; padding-top: 5px; margin: 5px 0; width: 10em;">
|
||||
<img src="/static/images/icons/voting-total.png" title="{% trans 'Votes cast' %}"> {{ poll.poll_votescast }}
|
||||
<img src="/static/images/icons/voting-total.png" title="{% trans 'Votes cast' %}"> {{ poll.print_votescast }}
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% if perms.application.can_manage_application %}
|
||||
|
@ -11,8 +11,8 @@
|
||||
</p>
|
||||
<p><b>{% trans "Short description" %}:</b> {{ poll.description }}</p>
|
||||
<i>-1 := {% trans 'majority' %}, -2 := {% trans 'undocumented' %}</i>
|
||||
<form action="" method="post">{% csrf_token %}
|
||||
<table>
|
||||
<form action="" method="post" class="small-form">{% csrf_token %}
|
||||
<table style="width:auto">
|
||||
<tr>
|
||||
<th>Option</th>
|
||||
{% for value in poll.get_vote_values %}
|
||||
|
@ -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 <b>%s</b> 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 <b>%s</b>?') % name, object.get_absolute_url('delete'))
|
||||
|
||||
def gen_confirm_form(self, request, message, url):
|
||||
messages.warning(request, '%s<form action="%s" method="post"><input type="hidden" value="%s" name="csrfmiddlewaretoken"><input type="submit" value="%s" /> <input type="button" value="%s"></form>' % (message, url, csrf(request)['csrf_token'], _("Yes"), _("No")))
|
||||
|
||||
|
||||
class PDFView(PermissionMixin, View):
|
||||
filename = 'No_Name'
|
||||
|
Loading…
Reference in New Issue
Block a user