2011-07-31 10:46:29 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
openslides.agenda.api
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Useful functions for the agenda app.
|
|
|
|
|
|
|
|
:copyright: 2011 by the OpenSlides team, see AUTHORS.
|
|
|
|
:license: GNU GPL, see LICENSE for more details.
|
|
|
|
"""
|
|
|
|
|
2011-09-03 12:45:19 +02:00
|
|
|
from django.utils.translation import ugettext as _
|
|
|
|
from django.contrib import messages
|
|
|
|
from django.core.context_processors import csrf
|
|
|
|
|
2011-07-31 10:46:29 +02:00
|
|
|
from openslides.system.api import config_get
|
2012-02-06 22:22:16 +01:00
|
|
|
from projector.api import get_active_slide
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
def is_summary():
|
|
|
|
"""
|
|
|
|
True, if a summery shall be displayed
|
|
|
|
"""
|
2012-02-09 02:29:38 +01:00
|
|
|
if config_get('agenda_summary', False):
|
2011-07-31 10:46:29 +02:00
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2012-02-09 02:29:38 +01:00
|
|
|
|
2011-07-31 10:46:29 +02:00
|
|
|
def children_list(items):
|
|
|
|
"""
|
|
|
|
Return a list for items with all childitems in the right order.
|
|
|
|
"""
|
|
|
|
l = []
|
|
|
|
for item in items:
|
|
|
|
l.append(item)
|
|
|
|
if item.children:
|
|
|
|
l += children_list(item.children)
|
|
|
|
return l
|
2011-09-03 12:45:19 +02:00
|
|
|
|
2012-02-09 02:29:38 +01:00
|
|
|
|
2011-11-14 21:52:33 +01:00
|
|
|
def gen_confirm_form_for_items(request, message, url, singleitem=None):
|
|
|
|
if singleitem:
|
|
|
|
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")))
|
|
|
|
else:
|
|
|
|
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"), _("Yes, with all child items."), _("No")))
|
2011-09-03 12:45:19 +02:00
|
|
|
|
2012-02-09 02:29:38 +01:00
|
|
|
|
2011-09-03 12:45:19 +02:00
|
|
|
def del_confirm_form_for_items(request, object, name=None):
|
|
|
|
if name is None:
|
|
|
|
name = object
|
2011-11-14 21:52:33 +01:00
|
|
|
if object.children:
|
|
|
|
gen_confirm_form_for_items(request, _('Do you really want to delete <b>%s</b>?') % name, object.get_absolute_url('delete'), False)
|
|
|
|
else:
|
2012-02-03 23:12:28 +01:00
|
|
|
gen_confirm_form_for_items(request, _('Do you really want to delete <b>%s</b>?') % name, object.get_absolute_url('delete'), True)
|