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 %}