diff --git a/openslides/agenda/models.py b/openslides/agenda/models.py index dac9b92d8..57b8cdf7f 100644 --- a/openslides/agenda/models.py +++ b/openslides/agenda/models.py @@ -139,7 +139,7 @@ register_slidemodel(Item, model_name=_('Agenda Item')) from projector.api import register_slidefunc from agenda.slides import agenda_show -register_slidefunc(_('Agenda'), agenda_show) +register_slidefunc(_('Agenda'), agenda_show, weight=-1) from django.dispatch import receiver diff --git a/openslides/projector/api.py b/openslides/projector/api.py index 7a8a12d68..3a09dadc2 100644 --- a/openslides/projector/api.py +++ b/openslides/projector/api.py @@ -1,5 +1,6 @@ from config.models import config from projector import SLIDE, Slide +from django.template.loader import render_to_string def get_slide_from_sid(sid): @@ -35,31 +36,36 @@ def set_active_slide(sid): config["presentation"] = sid -def register_slidemodel(model, model_name=None): +def register_slidemodel(model, model_name=None, control_template=None, weight=0): #TODO: Warn if there already is a slide with this prefix if model_name is None: model_name = model.prefix + if control_template is None: + control_template = 'projector/default_control_slidemodel.html' + category = model.__module__.split('.')[0] - SLIDE[model.prefix] = Slide( + SLIDE[model_name] = Slide( model_slide=True, model=model, category=category, key=model.prefix, model_name=model_name, + control_template=control_template, + weight=weight, ) -def register_slidefunc(key, func): +def register_slidefunc(key, func, control_template=None, weight=0): #TODO: Warn if there already is a slide with this prefix + if control_template is None: + control_template = 'projector/default_control_slidefunc.html' category = func.__module__.split('.')[0] SLIDE[key] = Slide( model_slide=False, func=func, category=category, key=key, + control_template=control_template, + weight=weight, ) - - -#def get_possible_slides(): - diff --git a/openslides/projector/projector.py b/openslides/projector/projector.py index 34765d2eb..d2ef0db28 100644 --- a/openslides/projector/projector.py +++ b/openslides/projector/projector.py @@ -48,14 +48,15 @@ class SlideMixin(object): class Slide(object): - def __init__(self, model_slide=False, func=None, model=None, category=None, key=None, model_name=''): + def __init__(self, model_slide=False, func=None, model=None, category=None, + key=None, model_name='', control_template='', weight=0): """ model_slide: Boolean if the value is a Model. func: The function to call. Only if modelslide is False. model: The model. Only if modelslide is True. model_name: The name shown for the model. category: The category to show this Slide. - key: the key in the slide object to find myself. + key: the key in the slide object to find itself. """ self.model_slide = model_slide self.func = func @@ -63,9 +64,14 @@ class Slide(object): self.model_name = model_name self.category = category self.key = key + self.control_template = control_template + self.weight = weight def get_items(self): - return self.model.objects.all() + try: + return self.model.objects.all() + except AttributeError: + return 'No Model' @receiver(projector_messages, dispatch_uid="projector_countdown") diff --git a/openslides/projector/signals.py b/openslides/projector/signals.py index 1bd2cd60b..41e227880 100644 --- a/openslides/projector/signals.py +++ b/openslides/projector/signals.py @@ -13,3 +13,5 @@ from django.dispatch import Signal projector_messages = Signal(providing_args=['register', 'call']) + +projector_control_box = Signal() diff --git a/openslides/projector/templates/projector/control.html b/openslides/projector/templates/projector/control.html index e79ec645f..17d187167 100644 --- a/openslides/projector/templates/projector/control.html +++ b/openslides/projector/templates/projector/control.html @@ -55,33 +55,19 @@
- {% for category, slides in categories.items %} + {% for category, group in categories.items %} {% if category != 'projector' %}
-
{{ category }}
+ {% with category_big=category|capfirst %} +
{% trans category_big %}
+ {% endwith %}
- {% for slide in slides %} - {% if slide.model_slide %} -
    - {% for slide in slide.get_items %} -
  • - {% for i in slide.get_ancestors %}   {% endfor %} - {{ slide }} - {% if slide.children.exists %} - - {% endif %} -
  • - {% endfor %} -
- {% else %} -
-
    -
  • {{ slide.key }}
  • -
+ {% for slides in group %} + {% if slides.control_template %} + {% include slides.control_template %} + {% endif %} + {% if not forloop.last %} +
{% endif %} {% endfor %}
diff --git a/openslides/projector/templates/projector/default_control_slidefunc.html b/openslides/projector/templates/projector/default_control_slidefunc.html new file mode 100644 index 000000000..b65b1f817 --- /dev/null +++ b/openslides/projector/templates/projector/default_control_slidefunc.html @@ -0,0 +1,12 @@ +{% load staticfiles %} +{% load i18n %} + + + diff --git a/openslides/projector/templates/projector/default_control_slidemodel.html b/openslides/projector/templates/projector/default_control_slidemodel.html new file mode 100644 index 000000000..f2c5ce499 --- /dev/null +++ b/openslides/projector/templates/projector/default_control_slidemodel.html @@ -0,0 +1,14 @@ +{% load staticfiles %} +{% load i18n %} + + + diff --git a/openslides/projector/views.py b/openslides/projector/views.py index d55749736..bb4bd187c 100644 --- a/openslides/projector/views.py +++ b/openslides/projector/views.py @@ -18,6 +18,8 @@ from django.core.urlresolvers import reverse from django.contrib import messages from django.utils.translation import ugettext as _ from django.utils.datastructures import SortedDict +from django.dispatch import receiver +from django.template.loader import render_to_string from utils.views import TemplateView, RedirectView @@ -31,8 +33,9 @@ from config.models import config from api import get_active_slide, set_active_slide from projector import SLIDE from models import ProjectorMessage -from openslides.projector.signals import projector_messages +from openslides.projector.signals import projector_messages, projector_control_box +from django.utils.importlib import import_module import settings @@ -69,12 +72,20 @@ class ControlView(TemplateView): categories[slide.category] = [] categories[slide.category].append(slide) - ordered_categories = SortedDict() + tmp_categories = categories + categories = SortedDict() for app in settings.INSTALLED_APPS: - if app in categories: - ordered_categories[app] = categories[app] + if app in tmp_categories: + tmp_categories[app].sort(key=lambda slide: slide.weight) + categories[app] = tmp_categories[app] + + + ## for receiver, response in projector_control_box.send(sender='ControllView'): + ## if response is not None: + ## categories[response[0]] = response[1] + context.update({ - 'categories': ordered_categories, + 'categories': categories, 'countdown_visible': config['countdown_visible'], 'countdown_time': config['agenda_countdown_time'], 'projector_messages': self.get_projector_messages(), @@ -195,3 +206,7 @@ def register_tab(request): selected=selected, ) + +## @receiver(projector_control_box, dispatch_uid="openslides.projector.views.projector_box") +## def projector_box(sender, **kwargs): + ## return ('header', 'text') diff --git a/openslides/utils/views.py b/openslides/utils/views.py index c284f33e4..692cd1b8a 100644 --- a/openslides/utils/views.py +++ b/openslides/utils/views.py @@ -258,9 +258,6 @@ def server_error(request, template_name='500.html'): @receiver(template_manipulation, dispatch_uid="send_register_tab") def send_register_tab(sender, request, context, **kwargs): - #del kwargs['signal'] - #register_tab.send(sender='register', request=request, context=context, **kwargs) - tabs = [] for app in settings.INSTALLED_APPS: try: