Added cache for the ajax-version of the projector
This commit is contained in:
parent
20e07c0af7
commit
c4e6466926
@ -134,3 +134,10 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
'openslides.utils.utils.revision',
|
||||
'openslides.utils.auth.anonymous_context_additions',
|
||||
)
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||
'LOCATION': 'openslidecache'
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
"""
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.importlib import import_module
|
||||
@ -85,6 +86,8 @@ def set_active_slide(sid, argument=None):
|
||||
"""
|
||||
config["presentation"] = sid
|
||||
config['presentation_argument'] = argument
|
||||
cache.delete('projector_content')
|
||||
cache.delete('projector_scrollcontent')
|
||||
|
||||
|
||||
def register_slidemodel(model, model_name=None, control_template=None,
|
||||
|
@ -15,6 +15,7 @@ from time import time
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.core.cache import cache
|
||||
from django.core.context_processors import csrf
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import transaction
|
||||
@ -107,10 +108,19 @@ class Projector(TemplateView, AjaxMixin):
|
||||
return context
|
||||
|
||||
def get_ajax_context(self, **kwargs):
|
||||
content = render_block_to_string(self.get_template_names()[0],
|
||||
'content', self.data)
|
||||
scrollcontent = render_block_to_string(self.get_template_names()[0],
|
||||
'scrollcontent', self.data)
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
context = super(Projector, self).get_ajax_context(**kwargs)
|
||||
content_hash = hash(content)
|
||||
|
Loading…
Reference in New Issue
Block a user