Example #1
0
    def get_ajax_context(self, **kwargs):
        content = cache.get('projector_content')
        if not content:
            content = render_block_to_string(self.get_template_names()[0],
                                             'content', self.data)
            cache.set('projector_content', content, 1)

        scrollcontent = cache.get('projector_scrollcontent')
        if not scrollcontent:
            scrollcontent = render_block_to_string(
                self.get_template_names()[0], 'scrollcontent', self.data)
            cache.set('projector_scrollcontent', scrollcontent, 1)

        # TODO: do not call the hole data-methode, if we only need some vars
        data = cache.get('projector_data')
        if not data:
            data = self.data
            cache.set('projector_data', data)

        context = super(Projector, self).get_ajax_context(**kwargs)
        content_hash = hash(content)
        context.update({
            'content': content,
            'scrollcontent': scrollcontent,
            'time': datetime.now().strftime('%H:%M'),
            'overlays': data['overlays'],
            'title': data['title'],
            'bigger': config['bigger'],
            'up': config['up'],
            'content_hash': content_hash,
        })
        return context
Example #2
0
    def get_ajax_context(self, **kwargs):
        language = self.request.LANGUAGE_CODE
        content = cache.get('projector_content_' + language)
        if not content:
            content = render_block_to_string(self.get_template_names()[0],
                                             'content', self.data)
            cache.set('projector_content_' + language, content, 1)

        scrollcontent = cache.get('projector_scrollcontent')
        if not scrollcontent:
            scrollcontent = render_block_to_string(
                self.get_template_names()[0], 'scrollcontent', self.data)
            cache.set('projector_scrollcontent_' + language, scrollcontent, 1)

        # TODO: do not call the hole data-methode, if we only need some vars
        data = cache.get('projector_data_' + language)
        if not data:
            data = self.data
            cache.set('projector_data_' + language, data)
        # clear cache if countdown is enabled
        if config['countdown_state'] == 'active':
            clear_projector_cache()
        context = super(Projector, self).get_ajax_context(**kwargs)
        content_hash = hash(content)
        context.update({
            'content': content,
            'scrollcontent': scrollcontent,
            'time': datetime.now().strftime('%H:%M'),
            'overlays': data['overlays'],
            'title': data['title'],
            'bigger': config['bigger'],
            'up': config['up'],
            'content_hash': content_hash,
        })
        return context
Example #3
0
    def get_ajax_context(self, **kwargs):
        content = cache.get('projector_content')
        if not content:
            content = render_block_to_string(
                self.get_template_names()[0],
                'content', self.data)
            cache.set('projector_content', content, 1)

        scrollcontent = cache.get('projector_scrollcontent')
        if not scrollcontent:
            scrollcontent = render_block_to_string(
                self.get_template_names()[0],
                'scrollcontent', self.data)
            cache.set('projector_scrollcontent', scrollcontent, 1)

        # TODO: do not call the hole data-methode, if we only need some vars
        data = cache.get('projector_data')
        if not data:
            data = self.data
            cache.set('projector_data', data)

        context = super(Projector, self).get_ajax_context(**kwargs)
        content_hash = hash(content)
        context.update({
            'content': content,
            'scrollcontent': scrollcontent,
            'time': datetime.now().strftime('%H:%M'),
            'overlays': data['overlays'],
            'title': data['title'],
            'bigger': config['bigger'],
            'up': config['up'],
            'content_hash': content_hash,
        })
        return context
Example #4
0
def beamerhome(request):
    """
    Shows a active Slide.
    """
    data = {'ajax': 'on'}
    template = ''
    try:
        item = get_active_item()
        votes = assignment_votes(item)
        polls = assignment_polls(item)
        if is_summary():
            items = item.children.filter(hidden=False)
            data['items'] = items
            data['title'] = item.title
            template = 'beamer/overview.html'
        else:
            data['item'] = item.cast()
            data['title'] = item.title
            data['votes'] = votes
            data['polls'] = polls
            template = 'beamer/%shome.html' % (item.type)
    except Item.DoesNotExist:
        items = Item.objects.filter(parent=None).filter(hidden=False)\
        .order_by('weight')
        data['items'] = items
        data['title'] = _("Agenda")
        template = 'beamer/overview.html'

    if request.is_ajax():
        content = render_block_to_string(template, 'content', data)
        jsondata = {'content': content,
                    'title': data['title'],
                    'time': datetime.now().strftime('%H:%M'),
                    'bigger': config_get('bigger'),
                    'up': config_get('up'),
                    'countdown_visible': config_get('countdown_visible'),
                    'countdown_time': config_get('agenda_countdown_time'),
                    'countdown_control': config_get('countdown_control'),
                    }
        return ajax_request(jsondata)
    else:
        return render_to_response(template,
            data,
            context_instance=RequestContext(request))