From 9dc799ef5eddfb9d02b6bca34932f7738b8ddbdd Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Mon, 29 Oct 2012 23:26:10 +0100 Subject: [PATCH] fixed projector_cache. It still does not work, but it does show changes on slides now --- openslides/projector/api.py | 5 +++++ openslides/projector/projector.py | 6 ++++++ openslides/projector/views.py | 11 +++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/openslides/projector/api.py b/openslides/projector/api.py index de0cf03b8..6bcc04772 100644 --- a/openslides/projector/api.py +++ b/openslides/projector/api.py @@ -86,8 +86,13 @@ def set_active_slide(sid, argument=None): """ config["presentation"] = sid config['presentation_argument'] = argument + clear_projector_cache() + + +def clear_projector_cache(): cache.delete('projector_content') cache.delete('projector_scrollcontent') + cache.delete('projector_data') def register_slidemodel(model, model_name=None, control_template=None, diff --git a/openslides/projector/projector.py b/openslides/projector/projector.py index 5ebd81ab3..9247a010b 100644 --- a/openslides/projector/projector.py +++ b/openslides/projector/projector.py @@ -58,6 +58,12 @@ class SlideMixin(object): """ 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): """ diff --git a/openslides/projector/views.py b/openslides/projector/views.py index 54fa7a866..10c22f1ea 100644 --- a/openslides/projector/views.py +++ b/openslides/projector/views.py @@ -122,14 +122,21 @@ class Projector(TemplateView, AjaxMixin): 'scrollcontent', self.data) 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) content_hash = hash(content) context.update({ 'content': content, 'scrollcontent': scrollcontent, 'time': datetime.now().strftime('%H:%M'), - 'overlays': self.data['overlays'], - 'title': self.data['title'], + 'overlays': data['overlays'], + 'title': data['title'], 'bigger': config['bigger'], 'up': config['up'], 'content_hash': content_hash,