Ejemplo n.º 1
0
def agenda_slide(**kwargs):
    """
    Return the html code for all slides of the agenda app.

    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.

    The function is registered during app loading.
    """
    item_pk = kwargs.get('pk', None)
    slide_type = kwargs.get('type', None)

    try:
        item = Item.objects.get(pk=item_pk)
    except Item.DoesNotExist:
        item = None

    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
        slide = render_to_string('agenda/item_slide_summary.html', context)

    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
        }
        slide = render_to_string('agenda/item_slide_list_of_speaker.html',
                                 context)

    elif item.content_object:
        slide_dict = {
            'callback': item.content_object.slide_callback_name,
            'pk': item.content_object.pk
        }
        slide = get_projector_content(slide_dict)

    else:
        context = {'item': item}
        slide = render_to_string('agenda/item_slide.html', context)
    return slide
Ejemplo n.º 2
0
def agenda_slide(**kwargs):
    """
    Return the html code for all slides of the agenda app.

    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.
    """
    item_pk = kwargs.get('pk', None)
    slide_type = kwargs.get('type', None)

    try:
        item = Item.objects.get(pk=item_pk)
    except Item.DoesNotExist:
        item = None

    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
        slide = render_to_string('agenda/item_slide_summary.html', context)

    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}
        slide = render_to_string('agenda/item_slide_list_of_speaker.html', context)

    elif item.content_object:
        slide_dict = {
            'callback': item.content_object.slide_callback_name,
            'pk': item.content_object.pk}
        slide = get_projector_content(slide_dict)

    else:
        context = {'item': item}
        slide = render_to_string('agenda/item_slide.html', context)
    return slide
Ejemplo n.º 3
0
    def test_get_projector_content(self, mock_default_slide):
        mock_slide = MagicMock()
        mock_slide.return_value = 'slide content'

        with patch.dict('openslides.projector.api.slide_callback',
                        values={'mock_slide': mock_slide}):
            value = projector_api.get_projector_content({'callback': 'mock_slide'})
            self.assertEqual(value, 'slide content')

            projector_api.get_projector_content({'callback': 'unknown_slide'})
            self.assertTrue(mock_default_slide.called)

            with patch('openslides.projector.api.config',
                       {'projector_active_slide': {'callback': 'mock_slide'}}):
                value = projector_api.get_projector_content()
                self.assertEqual(value, 'slide content')

            mock_slide.side_effect = projector_api.SlideError
            projector_api.get_projector_content({'callback': 'mock_slide'})
            self.assertTrue(mock_default_slide.called)
Ejemplo n.º 4
0
    def test_get_projector_content(self, mock_default_slide):
        mock_slide = MagicMock()
        mock_slide.return_value = 'slide content'

        with patch.dict('openslides.projector.api.slide_callback',
                        values={'mock_slide': mock_slide}):
            value = projector_api.get_projector_content({'callback': 'mock_slide'})
            self.assertEqual(value, 'slide content')

            projector_api.get_projector_content({'callback': 'unknown_slide'})
            self.assertTrue(mock_default_slide.called)

            with patch('openslides.projector.api.config',
                       {'projector_active_slide': {'callback': 'mock_slide'}}):
                value = projector_api.get_projector_content()
                self.assertEqual(value, 'slide content')

            mock_slide.side_effect = projector_api.SlideError
            projector_api.get_projector_content({'callback': 'mock_slide'})
            self.assertTrue(mock_default_slide.called)