Exemple #1
0
    def data(self):
        try:
            return self._data
        except AttributeError:
            pass
        sid = self.kwargs['sid']
        if sid is None:
            try:
                data = get_active_slide()
            except AttributeError: #TODO: It has to be an Slide.DoesNotExist
                data = None
            ajax = 'on'
            active_sid = get_active_slide(True)
        else:
            data = get_slide_from_sid(sid)
            ajax = 'off'

        if data is None:
            data = {
                'title': config['event_name'],
                'template': 'projector/default.html',
            }
        data['overlays'] = []
        data['ajax'] = ajax

        # Projector Overlays
        if self.kwargs['sid'] is None:
            active_defs = ProjectorOverlay.objects.filter(active=True) \
                .filter(Q(sid=active_sid) | Q(sid=None)).values_list('def_name',
                flat=True)
            for receiver, response in projector_overlays.send(sender=sid,
                                        register=False, call=active_defs):
                if response is not None:
                    data['overlays'].append(response)
        self._data = data
        return data
Exemple #2
0
def get_widgets(request):
    """
    Return the widgets of the projector app
    """
    widgets = []

    # welcome widget
    context = {
        'welcometext': config['welcome_text']}
    widgets.append(Widget(
        name='welcome',
        display_name=config['welcome_title'],
        template='projector/welcome_widget.html',
        context=context,
        permission_required='projector.can_see_dashboard',
        default_column=1))

    # Projector live view widget
    widgets.append(Widget(
        name='live_view',
        display_name=_('Projector live view'),
        template='projector/live_view_widget.html',
        context = RequestContext(request, {}),
        permission_required='projector.can_see_projector',
        default_column=2))

    # Overlay Widget
    overlays = []
    for receiver, name in projector_overlays.send(sender='registerer',
                                                  register=True):
        if name is not None:
            try:
                projector_overlay = ProjectorOverlay.objects.get(
                    def_name=name)
            except ProjectorOverlay.DoesNotExist:
                projector_overlay = ProjectorOverlay(def_name=name,
                    active=False)
                projector_overlay.save()
            overlays.append(projector_overlay)

    context = {
            'overlays':overlays,
            'countdown_time': config['countdown_time'],
            'countdown_state' : config['countdown_state']}
    context.update(csrf(request))
    widgets.append(Widget(
        name='overlays',
        display_name=_('Overlays'),
        template='projector/overlay_widget.html',
        permission_required='projector.can_manage_projector',
        default_column=2,
        context=context))


    # Custom slide widget
    context = {
        'slides': ProjectorSlide.objects.all().order_by('weight'),
        'welcomepage_is_active': not bool(config["presentation"])}
    widgets.append(Widget(
        name='custom_slide',
        display_name=_('Custom Slides'),
        template='projector/custom_slide_widget.html',
        context=context,
        permission_required='projector.can_manage_projector',
        default_column=2))

    return widgets