From ccdce52caaa66c8c9647a5334e7ecd9fae61e8d3 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Fri, 16 Mar 2012 12:28:42 +0100 Subject: [PATCH] start a way to send messages to the projector. Start to use this api for the countdown --- openslides/projector/projector.py | 19 +++++++++++++++++++ openslides/projector/signals.py | 15 +++++++++++++++ .../projector/templates/base-projector.html | 8 +++++++- .../templates/projector/base_projector.html | 2 +- .../templates/projector/control.html | 4 ++-- openslides/projector/urls.py | 2 +- openslides/projector/views.py | 15 +++++++++++---- openslides/static/javascript/projector.js | 1 + openslides/static/styles/projector.css | 5 +++-- openslides/system/models.py | 2 +- openslides/utils/views.py | 2 +- 11 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 openslides/projector/signals.py diff --git a/openslides/projector/projector.py b/openslides/projector/projector.py index 6cafd5696..a009c894d 100644 --- a/openslides/projector/projector.py +++ b/openslides/projector/projector.py @@ -1,5 +1,12 @@ +from datetime import datetime + +from django.dispatch import receiver + from system import config +from openslides.projector.signals import projector_messages + + SLIDE = {} class SlideMixin(object): @@ -58,3 +65,15 @@ class Slide(object): def get_items(self): return self.model.objects.all() + + +@receiver(projector_messages, dispatch_uid="projector_countdown") +def countdown(sender, **kwargs): + if config['countdown_visible']: + starttime = config['countdown_start'] + if type(starttime) != type(datetime.now()): + config['countdown_start'] = datetime.now() + starttime = config['countdown_start'] + #todo: return the time passt sinth starttime + return datetime.now() - starttime + return None diff --git a/openslides/projector/signals.py b/openslides/projector/signals.py new file mode 100644 index 000000000..5dbd32ef8 --- /dev/null +++ b/openslides/projector/signals.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" + openslides.projector.signals + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Defines Signals for the projector. + + :copyright: 2011 by the OpenSlides team, see AUTHORS. + :license: GNU GPL, see LICENSE for more details. +""" + +from django.dispatch import Signal + +projector_messages = Signal() diff --git a/openslides/projector/templates/base-projector.html b/openslides/projector/templates/base-projector.html index f239d95b6..f2d909b9e 100644 --- a/openslides/projector/templates/base-projector.html +++ b/openslides/projector/templates/base-projector.html @@ -29,7 +29,13 @@ {% now "H:i" %} -
0:00
+
+ +
{% block content %} diff --git a/openslides/projector/templates/projector/base_projector.html b/openslides/projector/templates/projector/base_projector.html index 087fa4e35..f38e43aa1 100644 --- a/openslides/projector/templates/projector/base_projector.html +++ b/openslides/projector/templates/projector/base_projector.html @@ -3,7 +3,7 @@ {% load tags %} {% load i18n %} -{% block title %}foasdfasdfafs {% endblock %} +{% block title %}{{ block.super}} – {% trans 'Projector' %} {% endblock %} {% block submenu %} {% url item_overview as url_itemoverview %} diff --git a/openslides/projector/templates/projector/control.html b/openslides/projector/templates/projector/control.html index 809391fa4..aee228a6f 100644 --- a/openslides/projector/templates/projector/control.html +++ b/openslides/projector/templates/projector/control.html @@ -54,8 +54,8 @@ {% trans "Countdown" %} ({{countdown_time}}{% trans "sec" %}) - {% if countdown_visible == "True" %}: - + {% if countdown_visible %}: + diff --git a/openslides/projector/urls.py b/openslides/projector/urls.py index 432fe666b..3801612dd 100644 --- a/openslides/projector/urls.py +++ b/openslides/projector/urls.py @@ -63,7 +63,7 @@ urlpatterns = patterns('projector.views', url(r'^countdown/hide/$', 'projector_countdown', {'command': 'hide'}, name='countdown_close'), - url(r'^countdown/reset/(?P