2013-08-04 12:59:11 +02:00
|
|
|
from django.template.loader import render_to_string
|
2012-07-12 14:06:58 +02:00
|
|
|
|
2013-08-04 12:59:11 +02:00
|
|
|
from openslides.config.api import config
|
2014-11-13 22:23:16 +01:00
|
|
|
from openslides.projector.api import get_projector_content
|
2013-03-18 12:34:47 +01:00
|
|
|
|
|
|
|
from .models import Item
|
|
|
|
|
2012-02-09 01:46:58 +01:00
|
|
|
|
2013-08-04 12:59:11 +02:00
|
|
|
def agenda_slide(**kwargs):
|
|
|
|
"""
|
|
|
|
Return the html code for all slides of the agenda app.
|
2013-03-18 12:34:47 +01:00
|
|
|
|
2013-08-04 12:59:11 +02:00
|
|
|
If no id is given, show a summary of all parent items.
|
|
|
|
|
|
|
|
If an id is given, show the item depending of the argument 'type'.
|
|
|
|
|
|
|
|
If 'type' is not set, show only the item.
|
|
|
|
|
|
|
|
If 'type' is 'summary', show a summary of all children of the item.
|
|
|
|
|
|
|
|
If 'type' is 'list_of_speakers', show the list of speakers for the item.
|
2014-11-13 22:23:16 +01:00
|
|
|
|
|
|
|
The function is registered during app loading.
|
2013-08-04 12:59:11 +02:00
|
|
|
"""
|
|
|
|
item_pk = kwargs.get('pk', None)
|
|
|
|
slide_type = kwargs.get('type', None)
|
|
|
|
|
|
|
|
try:
|
|
|
|
item = Item.objects.get(pk=item_pk)
|
|
|
|
except Item.DoesNotExist:
|
2013-11-12 08:36:46 +01:00
|
|
|
item = None
|
2013-08-04 12:59:11 +02:00
|
|
|
|
|
|
|
if slide_type == 'summary' or item is None:
|
|
|
|
context = {}
|
|
|
|
if item is None:
|
|
|
|
items = Item.objects.filter(parent=None, type__exact=Item.AGENDA_ITEM)
|
|
|
|
else:
|
|
|
|
items = item.get_children().filter(type__exact=Item.AGENDA_ITEM)
|
|
|
|
context['title'] = item.get_title()
|
|
|
|
context['items'] = items
|
2013-11-08 08:33:01 +01:00
|
|
|
slide = render_to_string('agenda/item_slide_summary.html', context)
|
2013-08-04 12:59:11 +02:00
|
|
|
|
|
|
|
elif slide_type == 'list_of_speakers':
|
|
|
|
list_of_speakers = item.get_list_of_speakers(
|
|
|
|
old_speakers_count=config['agenda_show_last_speakers'])
|
|
|
|
context = {'title': item.get_title(),
|
|
|
|
'item': item,
|
|
|
|
'list_of_speakers': list_of_speakers}
|
2013-11-08 08:33:01 +01:00
|
|
|
slide = render_to_string('agenda/item_slide_list_of_speaker.html', context)
|
2013-08-04 12:59:11 +02:00
|
|
|
|
|
|
|
elif item.content_object:
|
|
|
|
slide_dict = {
|
|
|
|
'callback': item.content_object.slide_callback_name,
|
|
|
|
'pk': item.content_object.pk}
|
2013-11-08 08:33:01 +01:00
|
|
|
slide = get_projector_content(slide_dict)
|
2013-08-04 12:59:11 +02:00
|
|
|
|
|
|
|
else:
|
|
|
|
context = {'item': item}
|
2013-11-08 08:33:01 +01:00
|
|
|
slide = render_to_string('agenda/item_slide.html', context)
|
|
|
|
return slide
|