fixed projector_cache.

It still does not work, but it does show changes on slides now
This commit is contained in:
Oskar Hahn 2012-10-29 23:26:10 +01:00
parent f4e1f83f15
commit 9dc799ef5e
3 changed files with 20 additions and 2 deletions

View File

@ -86,8 +86,13 @@ def set_active_slide(sid, argument=None):
""" """
config["presentation"] = sid config["presentation"] = sid
config['presentation_argument'] = argument config['presentation_argument'] = argument
clear_projector_cache()
def clear_projector_cache():
cache.delete('projector_content') cache.delete('projector_content')
cache.delete('projector_scrollcontent') cache.delete('projector_scrollcontent')
cache.delete('projector_data')
def register_slidemodel(model, model_name=None, control_template=None, def register_slidemodel(model, model_name=None, control_template=None,

View File

@ -58,6 +58,12 @@ class SlideMixin(object):
""" """
set_active_slide(self.sid) set_active_slide(self.sid)
def save(self, *args, **kwargs):
if self.active:
from api import clear_projector_cache
clear_projector_cache()
return super(SlideMixin, self).save(*args, **kwargs)
class Slide(object): class Slide(object):
""" """

View File

@ -122,14 +122,21 @@ class Projector(TemplateView, AjaxMixin):
'scrollcontent', self.data) 'scrollcontent', self.data)
cache.set('projector_scrollcontent', scrollcontent) cache.set('projector_scrollcontent', scrollcontent)
# 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) context = super(Projector, self).get_ajax_context(**kwargs)
content_hash = hash(content) content_hash = hash(content)
context.update({ context.update({
'content': content, 'content': content,
'scrollcontent': scrollcontent, 'scrollcontent': scrollcontent,
'time': datetime.now().strftime('%H:%M'), 'time': datetime.now().strftime('%H:%M'),
'overlays': self.data['overlays'], 'overlays': data['overlays'],
'title': self.data['title'], 'title': data['title'],
'bigger': config['bigger'], 'bigger': config['bigger'],
'up': config['up'], 'up': config['up'],
'content_hash': content_hash, 'content_hash': content_hash,