start a way to send messages to the projector. Start to use this api for the countdown

This commit is contained in:
Oskar Hahn 2012-03-16 12:28:42 +01:00
parent bf6d5fc798
commit ccdce52caa
11 changed files with 62 additions and 13 deletions

View File

@ -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

View File

@ -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()

View File

@ -29,7 +29,13 @@
{% now "H:i" %}
</div>
<div id="countdown">0:00</div>
<div id="messages">
<ul>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
</div>
<div id="content">
{% block content %}

View File

@ -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 %}

View File

@ -54,8 +54,8 @@
<!-- countdown -->
<input type="checkbox" name="countdown" onchange="document.location='{% if countdown_visible %}{% url countdown_close %}{% else %}{% url countdown_open %}{% endif %}'"{% if countdown_visible %} checked{% endif %}>
{% trans "Countdown" %} (<a href="{% url config_agenda %}">{{countdown_time}}{% trans "sec" %}</a>)
{% if countdown_visible == "True" %}:
<a class="projector_countdown" href="{% url countdown_reset countdown_time %}" title="{% trans 'Reset countdown' %}">
{% if countdown_visible %}:
<a class="projector_countdown" href="{% url countdown_reset %}" title="{% trans 'Reset countdown' %}">
<img src="/static/images/icons/media-skip-backward.png" />
</a>
<a class="projector_countdown" href="{% url countdown_start %}" title="{% trans 'Start countdown' %}">

View File

@ -63,7 +63,7 @@ urlpatterns = patterns('projector.views',
url(r'^countdown/hide/$', 'projector_countdown', {'command': 'hide'},
name='countdown_close'),
url(r'^countdown/reset/(?P<time>\d+)/$', 'projector_countdown', {'command': 'reset'},
url(r'^countdown/reset/$', 'projector_countdown', {'command': 'reset'},
name='countdown_reset'),
url(r'^countdown/start/$', 'projector_countdown', {'command': 'start'},

View File

@ -27,6 +27,7 @@ from system import config
from api import get_active_slide, set_active_slide
from projector import SLIDE
from openslides.projector.signals import projector_messages
class ControlView(TemplateView):
@ -76,6 +77,11 @@ def active_slide(request):
}
data['ajax'] = 'on'
data['messages'] = []
for receiver, response in projector_messages.send(sender='active_slide'):
if response is not None:
data['messages'].append(response)
if request.is_ajax():
content = render_block_to_string(data['template'], 'content', data)
@ -117,18 +123,19 @@ def projector_edit(request, direction):
return redirect(reverse('projector_control'))
@permission_required('agenda.can_manage_agenda')
@permission_required('projector.can_manage_projector')
def projector_countdown(request, command, time=60):
#todo: why is there the time argument?
if command == 'show':
config['countdown_visible'] = True
elif command == 'hide':
config['countdown_visible'] = False
elif command == 'reset':
config['countdown_control'] = 'reset'
config['countdown_start'] = datetime.now()
elif command == 'start':
config['countdown_control'] = 'start'
config['countdown_run'] = True
elif command == 'stop':
config['countdown_control'] = 'stop'
config['countdown_run'] = False
if request.is_ajax():
if command == "show":

View File

@ -14,6 +14,7 @@ function presentation_reload() {
$('#content li').css({'font-size': data.bigger + '%'}, 200);
$('#content #sidebar').css({'font-size': '16px'}, 0);
$('#content').animate({'margin-top': data.up + 'em'}, 200);
/*TODO: messages neu schreiben*/
if (data.countdown_visible == true)
$('#countdown').slideDown();

View File

@ -56,11 +56,12 @@ body{
padding-left:30px;
background: url(../images/icons/clock.png) no-repeat scroll 0px 4px;
}
#currentTime.ajax_error {
border-bottom: 4px solid red;
}
#countdown {
display: none;
#messages ul li {
font-size: 4em;
font-weight: bold;
padding: 0 1em;

View File

@ -50,7 +50,7 @@ class Config(object):
def load_config(self):
self.config = {}
for key, value in ConfigStore.objects.all().values_list():
self.config[key] = base64.decodestring(loads(str(value)))
self.config[key] = loads(base64.decodestring(str(value)))
def __getitem__(self, key):
try:

View File

@ -60,7 +60,7 @@ class PermissionMixin(object):
class TemplateView(_TemplateView, PermissionMixin):
def get_context_data(self, **kwargs):
context = super(TemplateView, self).get_context_data(**kwargs)
template_manipulation.send(sender=self, context=context, blub=True)
template_manipulation.send(sender=self, context=context)
return context