ask, if by deleting an item, if the childen shoud be deleted as well
This commit is contained in:
parent
e81de0fa48
commit
b626d049fe
@ -10,6 +10,10 @@
|
|||||||
:license: GNU GPL, see LICENSE for more details.
|
:license: GNU GPL, see LICENSE for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
from django.contrib import messages
|
||||||
|
from django.core.context_processors import csrf
|
||||||
|
|
||||||
from openslides.system.api import config_get
|
from openslides.system.api import config_get
|
||||||
|
|
||||||
|
|
||||||
@ -53,3 +57,11 @@ def children_list(items):
|
|||||||
if item.children:
|
if item.children:
|
||||||
l += children_list(item.children)
|
l += children_list(item.children)
|
||||||
return l
|
return l
|
||||||
|
|
||||||
|
def gen_confirm_form_for_items(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="submit" name="all" value="%s" /><input type="button" value="%s"></form>' % (message, url, csrf(request)['csrf_token'], _("Yes"), _("with children"), _("No")))
|
||||||
|
|
||||||
|
def del_confirm_form_for_items(request, object, name=None):
|
||||||
|
if name is None:
|
||||||
|
name = object
|
||||||
|
gen_confirm_form_for_items(request, _('Do you really want to delete <b>%s</b>?') % name, object.get_absolute_url('delete'))
|
||||||
|
@ -18,8 +18,8 @@ from django.contrib import messages
|
|||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from openslides.agenda.models import Item
|
from openslides.agenda.models import Item
|
||||||
from openslides.agenda.api import get_active_item, is_summary, children_list
|
from openslides.agenda.api import get_active_item, is_summary, children_list, \
|
||||||
|
del_confirm_form_for_items
|
||||||
from openslides.agenda.forms import ElementOrderForm, MODELFORM
|
from openslides.agenda.forms import ElementOrderForm, MODELFORM
|
||||||
from openslides.application.models import Application
|
from openslides.application.models import Application
|
||||||
from openslides.assignment.models import Assignment
|
from openslides.assignment.models import Assignment
|
||||||
@ -256,8 +256,15 @@ def delete(request, item_id):
|
|||||||
"""
|
"""
|
||||||
item = Item.objects.get(id=item_id).cast()
|
item = Item.objects.get(id=item_id).cast()
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
item.delete()
|
if 'all' in request.POST:
|
||||||
messages.success(request, _("Item <b>%s</b> was successfully deleted.") % item)
|
item.delete()
|
||||||
|
messages.success(request, _("Item <b>%s</b> and his children were successfully deleted.") % item)
|
||||||
|
else:
|
||||||
|
for child in item.children:
|
||||||
|
child.parent = item.parent
|
||||||
|
child.save()
|
||||||
|
item.delete()
|
||||||
|
messages.success(request, _("Item <b>%s</b> was successfully deleted.") % item)
|
||||||
else:
|
else:
|
||||||
del_confirm_form(request, item)
|
del_confirm_form_for_items(request, item)
|
||||||
return redirect(reverse('item_overview'))
|
return redirect(reverse('item_overview'))
|
||||||
|
Loading…
Reference in New Issue
Block a user