Merge pull request #28 from ostcar/projector_cache
Added cache for the ajax-version of the projector
This commit is contained in:
commit
e7aab1d2a8
@ -134,3 +134,10 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
|||||||
'openslides.utils.utils.revision',
|
'openslides.utils.utils.revision',
|
||||||
'openslides.utils.auth.anonymous_context_additions',
|
'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.conf import settings
|
||||||
|
from django.core.cache import cache
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.utils.datastructures import SortedDict
|
from django.utils.datastructures import SortedDict
|
||||||
from django.utils.importlib import import_module
|
from django.utils.importlib import import_module
|
||||||
@ -85,6 +86,8 @@ def set_active_slide(sid, argument=None):
|
|||||||
"""
|
"""
|
||||||
config["presentation"] = sid
|
config["presentation"] = sid
|
||||||
config['presentation_argument'] = argument
|
config['presentation_argument'] = argument
|
||||||
|
cache.delete('projector_content')
|
||||||
|
cache.delete('projector_scrollcontent')
|
||||||
|
|
||||||
|
|
||||||
def register_slidemodel(model, model_name=None, control_template=None,
|
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.conf import settings
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
|
from django.core.cache import cache
|
||||||
from django.core.context_processors import csrf
|
from django.core.context_processors import csrf
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
@ -107,10 +108,19 @@ class Projector(TemplateView, AjaxMixin):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
def get_ajax_context(self, **kwargs):
|
def get_ajax_context(self, **kwargs):
|
||||||
content = render_block_to_string(self.get_template_names()[0],
|
content = cache.get('projector_content')
|
||||||
'content', self.data)
|
if not content:
|
||||||
scrollcontent = render_block_to_string(self.get_template_names()[0],
|
content = render_block_to_string(
|
||||||
'scrollcontent', self.data)
|
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)
|
context = super(Projector, self).get_ajax_context(**kwargs)
|
||||||
content_hash = hash(content)
|
content_hash = hash(content)
|
||||||
|
Loading…
Reference in New Issue
Block a user