diff --git a/openslides/agenda/models.py b/openslides/agenda/models.py index b924c4d20..f1b7efd78 100644 --- a/openslides/agenda/models.py +++ b/openslides/agenda/models.py @@ -22,7 +22,7 @@ from mptt.models import MPTTModel, TreeForeignKey from system import config -from projector.models import SlideMixin +from projector.projector import SlideMixin from projector.api import register_slidemodel from agenda.api import is_summary @@ -126,7 +126,6 @@ class Item(MPTTModel, SlideMixin): permissions = ( ('can_see_agenda', "Can see agenda"), ('can_manage_agenda', "Can manage agenda"), - ('can_see_projector', "Can see projector"), ) class MPTTMeta: diff --git a/openslides/projector/api.py b/openslides/projector/api.py index 86814da4e..b21cdb09b 100644 --- a/openslides/projector/api.py +++ b/openslides/projector/api.py @@ -1,5 +1,5 @@ from system import config -from projector.models import SLIDE, Slide +from projector import SLIDE, Slide def get_slide_from_sid(sid): diff --git a/openslides/projector/models.py b/openslides/projector/models.py index 032e2a155..07685a431 100644 --- a/openslides/projector/models.py +++ b/openslides/projector/models.py @@ -1,62 +1,26 @@ from django.db import models +from django.utils.translation import ugettext as _ + +from api import register_slidemodel +from projector import SlideMixin from system import config -SLIDE = {} -class SlideMixin(object): +class ProjectorSlide(models.Model, SlideMixin): + prefix = 'ProjectorSlide' - def slide(self): - """ - Return a map with all Data for a Slide - """ - return { - 'slide': self, - 'title': 'dummy-title', - 'template': 'projector/default.html', - } + title = models.CharField(max_length=100, verbose_name=_("Title")) + text = models.TextField(null=True, blank=True, verbose_name=_("Text")) + weight = models.IntegerField(default=0, verbose_name=_("Weight")) - @property - def sid(self): - """ - Return the sid from this Slide - """ - for key, value in SLIDE.iteritems(): - if type(self) == value.model: - return "%s-%d" % (key, self.id) - return None + def __unicode__(self): + return self.title - @property - def active(self): - """ - Return True, if the the slide is the active one. - """ - from projector.api import get_active_slide - return True if get_active_slide(only_sid=True) == self.sid else False + class Meta: + permissions = ( + ('can_manage_projector', "Can manage the projector"), + ('can_see_projector', "Can see projector"), + ) - def set_active(self): - """ - Appoint this item as the active one. - """ - config["presentation"] = "%s-%d" % (self.prefix, self.id) - - -class Slide(object): - def __init__(self, model_slide=False, func=None, model=None, category=None, key=None, model_name=''): - """ - 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. - """ - self.model_slide = model_slide - self.func = func - self.model = model - self.model_name = model_name - self.category = category - self.key = key - - def get_items(self): - return self.model.objects.all() +register_slidemodel(ProjectorSlide, category=_('Projector'), model_name=_('Projector Slide')) diff --git a/openslides/projector/projector.py b/openslides/projector/projector.py new file mode 100644 index 000000000..6cafd5696 --- /dev/null +++ b/openslides/projector/projector.py @@ -0,0 +1,60 @@ +from system import config + +SLIDE = {} + +class SlideMixin(object): + + def slide(self): + """ + Return a map with all Data for a Slide + """ + return { + 'slide': self, + 'title': 'dummy-title', + 'template': 'projector/default.html', + } + + @property + def sid(self): + """ + Return the sid from this Slide + """ + for key, value in SLIDE.iteritems(): + if type(self) == value.model: + return "%s-%d" % (key, self.id) + return None + + @property + def active(self): + """ + Return True, if the the slide is the active one. + """ + from api import get_active_slide + return True if get_active_slide(only_sid=True) == self.sid else False + + def set_active(self): + """ + Appoint this item as the active one. + """ + config["presentation"] = "%s-%d" % (self.prefix, self.id) + + +class Slide(object): + def __init__(self, model_slide=False, func=None, model=None, category=None, key=None, model_name=''): + """ + 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. + """ + self.model_slide = model_slide + self.func = func + self.model = model + self.model_name = model_name + self.category = category + self.key = key + + def get_items(self): + return self.model.objects.all() diff --git a/openslides/projector/templates/projector/base_projector.html b/openslides/projector/templates/projector/base_projector.html index cedf9e410..087fa4e35 100644 --- a/openslides/projector/templates/projector/base_projector.html +++ b/openslides/projector/templates/projector/base_projector.html @@ -3,13 +3,16 @@ {% load tags %} {% load i18n %} +{% block title %}foasdfasdfafs {% endblock %} + {% block submenu %} {% url item_overview as url_itemoverview %} {% url item_new as url_itemnew %}

{%trans "Projector" %}

{% endblock %} diff --git a/openslides/projector/templates/projector/control.html b/openslides/projector/templates/projector/control.html index e2709ad07..809391fa4 100644 --- a/openslides/projector/templates/projector/control.html +++ b/openslides/projector/templates/projector/control.html @@ -50,79 +50,78 @@ {% block content %}

{% trans 'Projector' %}

+
+ + + {% trans "Countdown" %} ({{countdown_time}}{% trans "sec" %}) + {% if countdown_visible == "True" %}: + + + + + + + + + + {% endif %} +

+ + {% trans "Adjust projector view" %}: + + + + + + + + + + + + + + + +
- {% if perms.agenda.can_manage_agenda %} -
- - - {% trans "Countdown" %} ({{countdown_time}}{% trans "sec" %}) - {% if countdown_visible == "True" %}: - - - - - - - - - - {% endif %} -

- - {% trans "Adjust projector view" %}: - - - - - - - - - - - - - - - -
- {% endif %} - -{% for category, slides in categories.items %} -
-
-
{{ category }}
-
- {% for slide in slides %} - {% if slide.model_slide %} -
    - {% for item in slide.get_items %} -
  • {{ item }}
  • - {% endfor %} -
- {% else %} - # {{ slide.key }} - {% endif %} - {% endfor %} + {% for category, slides in categories.items %} +
+
+
{{ category }}
+
+ {% for slide in slides %} + {% if slide.model_slide %} +
    + {% for item in slide.get_items %} +
  • {{ item }}
  • + {% endfor %} +
+ {% else %} + # {{ slide.key }} + {% endif %} + {% endfor %} +
-
-{% endfor %} + {% endfor %} -
-
-
{% trans "Live View" %}
-
- +
+
+
{% trans "Hidden information" %}
+
+ TODO: list hidden agenda items +
+
-
-
{% trans "Hidden information" %}
-
- TODO: list hidden agenda items -
-
-
{% endblock %} diff --git a/openslides/projector/templates/projector/new.html b/openslides/projector/templates/projector/new.html new file mode 100644 index 000000000..607a4bc31 --- /dev/null +++ b/openslides/projector/templates/projector/new.html @@ -0,0 +1,25 @@ +{% extends "projector/base_projector.html" %} + +{% load tags %} +{% load i18n %} + +{% block title %}{{ block.super }} – {%trans "New Slide" %}{% endblock %} + +{% block content %} +

{% trans 'New Slide' %}

+
{% csrf_token %} + {{ form.as_p }} + + + + + +
+ +{% endblock %} diff --git a/openslides/projector/urls.py b/openslides/projector/urls.py index 9b4c6286b..432fe666b 100644 --- a/openslides/projector/urls.py +++ b/openslides/projector/urls.py @@ -12,7 +12,11 @@ from django.conf.urls.defaults import * -from projector.views import ControlView, ActivateView +from utils.views import CreateView + +from views import ControlView, ActivateView +from models import ProjectorSlide + urlpatterns = patterns('projector.views', url(r'^$', 'active_slide', @@ -28,6 +32,16 @@ urlpatterns = patterns('projector.views', name='projector_activate_slide', ), + url(r'^new/$', + CreateView.as_view( + success_url='projector_control', + model=ProjectorSlide, + template_name='projector/new.html', + permission_required='projector.can_manage_projector' + ), + name='projector_new', + ), + url(r'^bigger/$', 'projector_edit', {'direction': 'bigger'}, name='projector_bigger'), diff --git a/openslides/projector/views.py b/openslides/projector/views.py index 39010695d..60a0d4417 100644 --- a/openslides/projector/views.py +++ b/openslides/projector/views.py @@ -25,8 +25,8 @@ from utils.template import render_block_to_string from system import config -from projector.api import get_active_slide, set_active_slide -from projector.models import SLIDE +from api import get_active_slide, set_active_slide +from projector import SLIDE class ControlView(TemplateView): @@ -59,7 +59,7 @@ class ActivateView(RedirectView): return context -@permission_required('agenda.can_see_projector') +@permission_required('projector.can_see_projector') def active_slide(request): """ Shows the active Slide.