fixed changing language on the projector

This commit is contained in:
Oskar Hahn 2013-01-08 20:40:27 +01:00
parent 0684f5a458
commit b322f63a81
2 changed files with 10 additions and 8 deletions

View File

@ -89,9 +89,10 @@ def set_active_slide(sid, argument=None):
def clear_projector_cache():
cache.delete('projector_content')
cache.delete('projector_scrollcontent')
cache.delete('projector_data')
for language, __ in settings.LANGUAGES:
cache.delete('projector_content_' + language)
cache.delete('projector_scrollcontent_' + language)
cache.delete('projector_data_' + language)
def register_slidemodel(model, model_name=None, control_template=None, weight=0):

View File

@ -104,25 +104,26 @@ class Projector(TemplateView, AjaxMixin):
return context
def get_ajax_context(self, **kwargs):
content = cache.get('projector_content')
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', content, 1)
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', scrollcontent, 1)
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')
data = cache.get('projector_data_' + language)
if not data:
data = self.data
cache.set('projector_data', data)
cache.set('projector_data_' + language, data)
# clear cache if countdown is enabled
if config['countdown_state'] == 'active':
clear_projector_cache()