Show a defined value of last speakers

Some work on the design of the speaker-list on the projector
This commit is contained in:
Oskar Hahn 2013-04-27 10:16:32 +02:00 committed by Norman Jäckel
parent 0b85164b84
commit 52e16d2e34
6 changed files with 127 additions and 43 deletions

View File

@ -161,17 +161,24 @@ class Item(MPTTModel, SlideMixin):
speaker_query = Speaker.objects.filter(item=self) speaker_query = Speaker.objects.filter(item=self)
coming_speakers = speaker_query.filter(begin_time=None).order_by('weight') coming_speakers = speaker_query.filter(begin_time=None).order_by('weight')
old_speakers = speaker_query.exclude(begin_time=None).exclude(end_time=None).order_by('end_time')
old_speakers_count = config['agenda_show_last_speakers']
if old_speakers_count > 0:
old_speakers = speaker_query.exclude(end_time=None)
old_speakers = old_speakers[max(0, old_speakers.count()) - old_speakers_count:]
else:
old_speakers = speaker_query.none()
try: try:
actual_speaker = speaker_query.filter(end_time=None).exclude(begin_time=None).get() actual_speaker = speaker_query.filter(end_time=None).exclude(begin_time=None).get()
except Speaker.DoesNotExist: except Speaker.DoesNotExist:
actual_speaker = None actual_speaker = None
slice_items = max(0, old_speakers.count()-2) speakers = list(old_speakers) + [actual_speaker] + list(coming_speakers)
data = {'title': self.get_title(), data = {'title': self.get_title(),
'template': 'projector/agenda_list_of_speaker.html', 'template': 'projector/agenda_list_of_speaker.html',
'coming_speakers': coming_speakers, 'speakers': speakers,
'old_speakers': old_speakers[slice_items:], 'actual_speaker': actual_speaker,
'actual_speaker': actual_speaker} 'old_speakers_count': -(old_speakers_count + 1)}
elif self.related_sid: elif self.related_sid:
data = self.get_related_slide().slide() data = self.get_related_slide().slide()
else: else:

View File

@ -12,11 +12,11 @@
from django.dispatch import receiver from django.dispatch import receiver
from django import forms from django import forms
from django.utils.translation import ugettext_lazy, ugettext_noop from django.utils.translation import ugettext_lazy, ugettext_noop, ugettext as _
from django.template.loader import render_to_string from django.template.loader import render_to_string
from openslides.config.signals import config_signal from openslides.config.signals import config_signal
from openslides.config.api import ConfigVariable, ConfigPage from openslides.config.api import ConfigVariable, ConfigPage, config
from openslides.projector.signals import projector_overlays from openslides.projector.signals import projector_overlays
from openslides.projector.projector import Overlay from openslides.projector.projector import Overlay
@ -40,8 +40,15 @@ def setup_agenda_config_page(sender, **kwargs):
form_field=forms.CharField( form_field=forms.CharField(
widget=forms.DateTimeInput(format='%d.%m.%Y %H:%M'), widget=forms.DateTimeInput(format='%d.%m.%Y %H:%M'),
required=False, required=False,
label=ugettext_lazy('Begin of event'), label=_('Begin of event'),
help_text=ugettext_lazy('Input format: DD.MM.YYYY HH:MM'))) help_text=_('Input format: DD.MM.YYYY HH:MM')))
agenda_show_last_speakers = ConfigVariable(
name='agenda_show_last_speakers',
default_value=0,
form_field=forms.IntegerField(
min_value=0,
label=_('Number of last speakers, to show on the projector')))
extra_stylefiles = ['styles/timepicker.css', 'styles/jquery-ui/jquery-ui.custom.min.css'] extra_stylefiles = ['styles/timepicker.css', 'styles/jquery-ui/jquery-ui.custom.min.css']
extra_javascript = ['javascript/jquery-ui.custom.min.js', extra_javascript = ['javascript/jquery-ui.custom.min.js',
@ -53,7 +60,7 @@ def setup_agenda_config_page(sender, **kwargs):
url='agenda', url='agenda',
required_permission='config.can_manage', required_permission='config.can_manage',
weight=20, weight=20,
variables=(agenda_start_event_date_time,), variables=(agenda_start_event_date_time, agenda_show_last_speakers),
extra_context={'extra_stylefiles': extra_stylefiles, extra_context={'extra_stylefiles': extra_stylefiles,
'extra_javascript': extra_javascript}) 'extra_javascript': extra_javascript})
@ -80,8 +87,27 @@ def agenda_list_of_speakers(sender, **kwargs):
# Only show list of speakers on Agenda-Items # Only show list of speakers on Agenda-Items
return None return None
clear_projector_cache() clear_projector_cache()
speakers = Speaker.objects.filter(begin_time=None, item=slide)[:5]
context = {'speakers': speakers} speaker_query = Speaker.objects.filter(item=slide)
try:
actual_speaker = speaker_query.filter(end_time=None).exclude(begin_time=None).get()
except Speaker.DoesNotExist:
actual_speaker = None
coming_speakers = speaker_query.filter(begin_time=None)[:5]
old_speakers_count = config['agenda_show_last_speakers']
if old_speakers_count > 0:
old_speakers = speaker_query.exclude(end_time=None)
old_speakers = old_speakers[max(0, old_speakers.count()) - old_speakers_count:]
else:
old_speakers = speaker_query.none()
speakers = list(old_speakers) + [actual_speaker] + list(coming_speakers)
context = {
'actual_speaker': actual_speaker,
'speakers': speakers,
'old_speakers_count': -(old_speakers_count + 1)}
return render_to_string('agenda/overlay_speaker_projector.html', context) return render_to_string('agenda/overlay_speaker_projector.html', context)
return Overlay(name, get_widget_html, get_projector_html) return Overlay(name, get_widget_html, get_projector_html)

View File

@ -1,13 +1,57 @@
{% load i18n %} {% load i18n %}
{% load tags %}
<style type="text/css">
#overlay_list_of_speaker_box {
position: fixed;
bottom: 0;
right: 0;
border-radius: 0.4em;
border: 0.1em solid #777777;
background-color: #cccccc;
opacity: 0.9;
padding: 0 .5em;
margin: 1em;
z-index: 2;
width: 30%;
min-width: 200px;
}
#overlay_list_of_speaker_box h3 {
margin: 5px;
}
#overlay_list_of_speaker_box ul {
list-style-type: None;
padding-left: 0;
margin: 5px;
}
#overlay_list_of_speaker_box li {
margin-bottom: 1px;
}
#overlay_list_of_speaker_box li span.number {
display: block;
float: left;
width: 1.3em;
}
</style>
<div id="overlay_list_of_speaker_box"> <div id="overlay_list_of_speaker_box">
{% if speakers %} {% if speakers %}
<h3>{% trans "List of speakers" %}:</h3> <h3>{% trans "List of speakers" %}:</h3>
<ol> <ul>
{% for speaker in speakers %} {% for speaker in speakers %}
<li>{{ speaker }}</li> <li>
{% if speaker == actual_speaker %}
<span class="number"></span><strong>
{% else %}
<span class="number">{{ forloop.counter|addition:old_speakers_count }}</span>
{% endif %}
<span class="name">{{ speaker }}</span>
{% if speaker == actual_speaker %}
</strong>
{% endif %}
</li>
{% endfor %} {% endfor %}
</ol> </ul>
{% else %} {% else %}
<i>{% trans 'The list of speakers is empty.' %}</i> <i>{% trans 'The list of speakers is empty.' %}</i>
{% endif %} {% endif %}

View File

@ -1,6 +1,7 @@
{% extends 'base-projector.html' %} {% extends 'base-projector.html' %}
{% load i18n %} {% load i18n %}
{% load tags %}
{% block title %}{{ block.super }} {{ item }}{% endblock %} {% block title %}{{ block.super }} {{ item }}{% endblock %}
@ -10,22 +11,36 @@
{% endblock %} {% endblock %}
{% block scrollcontent %} {% block scrollcontent %}
{% if old_speakers|length > 0 or actual_speaker %} <style type="text/css">
<ul class="list_of_speakers last_speakers"> ul#list_of_speakers {
{% for speaker in old_speakers %} list-style-type: None;
<li>{{ speaker }}</li> }
{% endfor %} #overlay_list_of_speaker_box li {
<li>{{ actual_speaker }} {% trans 'Actual Speaker' %}</li> margin-bottom: 1px;
</ul> }
{% endif %} #overlay_list_of_speaker_box li span.number {
display: block;
{% if coming_speakers %} float: left;
<ol class="list_of_speakers"> width: 1.3em;
{% for speaker in coming_speakers %} }
<li>{{ speaker }}</li> </style>
{% endfor %} {% if speakers %}
</ol> <ul id="list_of_speakers">
{% for speaker in speakers %}
<li>
{% if speaker == actual_speaker %}
<span class="number"></span><strong>
{% else %} {% else %}
<p><i>{% trans 'The list of speakers is empty.' %}</i></p> <span class="number">{{ forloop.counter|addition:old_speakers_count }}</span>
{% endif %}
<span class="name">{{ speaker }}</span>
{% if speaker == actual_speaker %}
</strong>
{% endif %}
</li>
{% endfor %}
</ul>
{% else %}
<i>{% trans 'The list of speakers is empty.' %}</i>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@ -73,19 +73,6 @@ body{
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
#overlay_list_of_speaker_box {
position: fixed;
bottom: 0;
right: 0;
border-radius: 0.4em;
border: 0.1em solid #777777;
background-color: #cccccc;
opacity: 0.9;
padding: 0 1em;
margin: 1em;
z-index: 2;
width: 50%;
}
/*** CONTENT ***/ /*** CONTENT ***/
#contentwrapper { #contentwrapper {

View File

@ -27,6 +27,11 @@ def get_config(key):
return config[key] return config[key]
@register.filter
def addition(value, add):
return int(value) + int(add)
@register.simple_tag @register.simple_tag
def active(request, pattern): def active(request, pattern):
if request.path.startswith(pattern): if request.path.startswith(pattern):