From 52e16d2e340d877d20ae4bc7dc0553da1d296c55 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sat, 27 Apr 2013 10:16:32 +0200 Subject: [PATCH] Show a defined value of last speakers Some work on the design of the speaker-list on the projector --- openslides/agenda/models.py | 17 +++++-- openslides/agenda/signals.py | 40 ++++++++++++--- .../agenda/overlay_speaker_projector.html | 50 +++++++++++++++++-- .../projector/agenda_list_of_speaker.html | 45 +++++++++++------ .../projector/static/styles/projector.css | 13 ----- openslides/utils/templatetags/tags.py | 5 ++ 6 files changed, 127 insertions(+), 43 deletions(-) diff --git a/openslides/agenda/models.py b/openslides/agenda/models.py index 37b12f0ee..d2a027ecf 100644 --- a/openslides/agenda/models.py +++ b/openslides/agenda/models.py @@ -161,17 +161,24 @@ class Item(MPTTModel, SlideMixin): speaker_query = Speaker.objects.filter(item=self) 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: actual_speaker = speaker_query.filter(end_time=None).exclude(begin_time=None).get() except Speaker.DoesNotExist: 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(), 'template': 'projector/agenda_list_of_speaker.html', - 'coming_speakers': coming_speakers, - 'old_speakers': old_speakers[slice_items:], - 'actual_speaker': actual_speaker} + 'speakers': speakers, + 'actual_speaker': actual_speaker, + 'old_speakers_count': -(old_speakers_count + 1)} elif self.related_sid: data = self.get_related_slide().slide() else: diff --git a/openslides/agenda/signals.py b/openslides/agenda/signals.py index 50ab1ece8..d607b2a8b 100644 --- a/openslides/agenda/signals.py +++ b/openslides/agenda/signals.py @@ -12,11 +12,11 @@ from django.dispatch import receiver 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 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.projector import Overlay @@ -40,8 +40,15 @@ def setup_agenda_config_page(sender, **kwargs): form_field=forms.CharField( widget=forms.DateTimeInput(format='%d.%m.%Y %H:%M'), required=False, - label=ugettext_lazy('Begin of event'), - help_text=ugettext_lazy('Input format: DD.MM.YYYY HH:MM'))) + label=_('Begin of event'), + 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_javascript = ['javascript/jquery-ui.custom.min.js', @@ -53,7 +60,7 @@ def setup_agenda_config_page(sender, **kwargs): url='agenda', required_permission='config.can_manage', 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_javascript': extra_javascript}) @@ -80,8 +87,27 @@ def agenda_list_of_speakers(sender, **kwargs): # Only show list of speakers on Agenda-Items return None 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 Overlay(name, get_widget_html, get_projector_html) diff --git a/openslides/agenda/templates/agenda/overlay_speaker_projector.html b/openslides/agenda/templates/agenda/overlay_speaker_projector.html index e1596a4cb..362dbf4f7 100644 --- a/openslides/agenda/templates/agenda/overlay_speaker_projector.html +++ b/openslides/agenda/templates/agenda/overlay_speaker_projector.html @@ -1,13 +1,57 @@ {% load i18n %} +{% load tags %} + +
{% if speakers %}

{% trans "List of speakers" %}:

-
    +
      {% for speaker in speakers %} -
    • {{ speaker }}
    • +
    • + {% if speaker == actual_speaker %} + + {% else %} + {{ forloop.counter|addition:old_speakers_count }} + {% endif %} + {{ speaker }} + {% if speaker == actual_speaker %} + + {% endif %} +
    • {% endfor %} -
+ {% else %} {% trans 'The list of speakers is empty.' %} {% endif %} diff --git a/openslides/agenda/templates/projector/agenda_list_of_speaker.html b/openslides/agenda/templates/projector/agenda_list_of_speaker.html index 857c42c96..184a3a74d 100644 --- a/openslides/agenda/templates/projector/agenda_list_of_speaker.html +++ b/openslides/agenda/templates/projector/agenda_list_of_speaker.html @@ -1,6 +1,7 @@ {% extends 'base-projector.html' %} {% load i18n %} +{% load tags %} {% block title %}{{ block.super }} – {{ item }}{% endblock %} @@ -10,22 +11,36 @@ {% endblock %} {% block scrollcontent %} - {% if old_speakers|length > 0 or actual_speaker %} - - {% endif %} - - {% if coming_speakers %} -
    - {% for speaker in coming_speakers %} -
  1. {{ speaker }}
  2. + + {% if speakers %} +
      + {% for speaker in speakers %} +
    • + {% if speaker == actual_speaker %} + + {% else %} + {{ forloop.counter|addition:old_speakers_count }} + {% endif %} + {{ speaker }} + {% if speaker == actual_speaker %} + + {% endif %} +
    • {% endfor %} -
+ {% else %} -

{% trans 'The list of speakers is empty.' %}

+ {% trans 'The list of speakers is empty.' %} {% endif %} {% endblock %} diff --git a/openslides/projector/static/styles/projector.css b/openslides/projector/static/styles/projector.css index 8ceb44822..fbff317f2 100644 --- a/openslides/projector/static/styles/projector.css +++ b/openslides/projector/static/styles/projector.css @@ -73,19 +73,6 @@ body{ width: 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 ***/ #contentwrapper { diff --git a/openslides/utils/templatetags/tags.py b/openslides/utils/templatetags/tags.py index 7563ebfb2..93640a008 100644 --- a/openslides/utils/templatetags/tags.py +++ b/openslides/utils/templatetags/tags.py @@ -27,6 +27,11 @@ def get_config(key): return config[key] +@register.filter +def addition(value, add): + return int(value) + int(add) + + @register.simple_tag def active(request, pattern): if request.path.startswith(pattern):