2013-02-20 23:50:34 +01:00
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
"""
|
|
|
|
|
openslides.agenda.signals
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
Signals for the agenda app.
|
|
|
|
|
|
2013-03-01 17:13:12 +01:00
|
|
|
|
:copyright: (c) 2011–2013 by the OpenSlides team, see AUTHORS.
|
2013-02-20 23:50:34 +01:00
|
|
|
|
:license: GNU GPL, see LICENSE for more details.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from django.dispatch import receiver
|
2013-03-01 17:13:12 +01:00
|
|
|
|
from django import forms
|
2013-04-27 10:16:32 +02:00
|
|
|
|
from django.utils.translation import ugettext_lazy, ugettext_noop, ugettext as _
|
2013-03-18 12:34:47 +01:00
|
|
|
|
from django.template.loader import render_to_string
|
2013-02-20 23:50:34 +01:00
|
|
|
|
|
2013-03-01 17:13:12 +01:00
|
|
|
|
from openslides.config.signals import config_signal
|
2013-04-29 20:03:50 +02:00
|
|
|
|
from openslides.config.api import config, ConfigVariable, ConfigPage
|
2013-02-20 23:50:34 +01:00
|
|
|
|
|
2013-03-18 12:34:47 +01:00
|
|
|
|
from openslides.projector.signals import projector_overlays
|
|
|
|
|
from openslides.projector.projector import Overlay
|
2013-04-22 22:09:09 +02:00
|
|
|
|
from openslides.projector.api import (get_active_slide, get_slide_from_sid,
|
|
|
|
|
clear_projector_cache)
|
2013-03-18 12:34:47 +01:00
|
|
|
|
|
|
|
|
|
from .models import Speaker, Item
|
|
|
|
|
|
2013-02-20 23:50:34 +01:00
|
|
|
|
|
2013-03-01 17:13:12 +01:00
|
|
|
|
# TODO: Reinsert the datepicker scripts in the template
|
|
|
|
|
|
|
|
|
|
@receiver(config_signal, dispatch_uid='setup_agenda_config_page')
|
|
|
|
|
def setup_agenda_config_page(sender, **kwargs):
|
|
|
|
|
"""
|
|
|
|
|
Agenda config variables.
|
|
|
|
|
"""
|
|
|
|
|
# TODO: Insert validator for the format or use other field carefully.
|
|
|
|
|
agenda_start_event_date_time = ConfigVariable(
|
|
|
|
|
name='agenda_start_event_date_time',
|
|
|
|
|
default_value='',
|
|
|
|
|
form_field=forms.CharField(
|
|
|
|
|
widget=forms.DateTimeInput(format='%d.%m.%Y %H:%M'),
|
|
|
|
|
required=False,
|
2013-04-27 10:16:32 +02:00
|
|
|
|
label=_('Begin of event'),
|
|
|
|
|
help_text=_('Input format: DD.MM.YYYY HH:MM')))
|
|
|
|
|
|
|
|
|
|
agenda_show_last_speakers = ConfigVariable(
|
|
|
|
|
name='agenda_show_last_speakers',
|
2013-04-29 20:03:50 +02:00
|
|
|
|
default_value=1,
|
2013-04-27 10:16:32 +02:00
|
|
|
|
form_field=forms.IntegerField(
|
|
|
|
|
min_value=0,
|
2013-04-29 20:03:50 +02:00
|
|
|
|
label=_('Number of last speakers to be shown on the projector')))
|
2013-03-01 17:13:12 +01:00
|
|
|
|
|
|
|
|
|
extra_stylefiles = ['styles/timepicker.css', 'styles/jquery-ui/jquery-ui.custom.min.css']
|
|
|
|
|
extra_javascript = ['javascript/jquery-ui.custom.min.js',
|
|
|
|
|
'javascript/jquery-ui-timepicker-addon.min.js',
|
2013-04-03 14:51:19 +02:00
|
|
|
|
'javascript/jquery-ui-sliderAccess.min.js',
|
|
|
|
|
'javascript/agenda-config-datepicker.js']
|
2013-03-01 17:13:12 +01:00
|
|
|
|
|
|
|
|
|
return ConfigPage(title=ugettext_noop('Agenda'),
|
|
|
|
|
url='agenda',
|
|
|
|
|
required_permission='config.can_manage',
|
|
|
|
|
weight=20,
|
2013-04-27 10:16:32 +02:00
|
|
|
|
variables=(agenda_start_event_date_time, agenda_show_last_speakers),
|
2013-03-01 17:13:12 +01:00
|
|
|
|
extra_context={'extra_stylefiles': extra_stylefiles,
|
|
|
|
|
'extra_javascript': extra_javascript})
|
2013-03-18 12:34:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@receiver(projector_overlays, dispatch_uid="agenda_list_of_speakers")
|
|
|
|
|
def agenda_list_of_speakers(sender, **kwargs):
|
|
|
|
|
"""
|
|
|
|
|
Receiver for the list of speaker overlay.
|
|
|
|
|
"""
|
|
|
|
|
name = 'agenda_speaker'
|
|
|
|
|
|
|
|
|
|
def get_widget_html():
|
|
|
|
|
"""
|
|
|
|
|
Returns the the html-code to show in the overly-widget.
|
|
|
|
|
"""
|
|
|
|
|
return render_to_string('agenda/overlay_speaker_widget.html')
|
|
|
|
|
|
|
|
|
|
def get_projector_html():
|
|
|
|
|
"""
|
|
|
|
|
Returns an html-code to show on the projector.
|
|
|
|
|
"""
|
|
|
|
|
slide = get_slide_from_sid(get_active_slide(only_sid=True), element=True)
|
|
|
|
|
if not isinstance(slide, Item):
|
|
|
|
|
# Only show list of speakers on Agenda-Items
|
|
|
|
|
return None
|
2013-04-22 22:09:09 +02:00
|
|
|
|
clear_projector_cache()
|
2013-04-29 20:03:50 +02:00
|
|
|
|
list_of_speakers = slide.get_list_of_speakers(
|
|
|
|
|
old_speakers_count=config['agenda_show_last_speakers'],
|
|
|
|
|
coming_speakers_count=5)
|
|
|
|
|
context = {'list_of_speakers': list_of_speakers}
|
2013-03-18 12:34:47 +01:00
|
|
|
|
return render_to_string('agenda/overlay_speaker_projector.html', context)
|
|
|
|
|
|
|
|
|
|
return Overlay(name, get_widget_html, get_projector_html)
|