2012-04-14 09:47:34 +02:00
|
|
|
from time import time
|
2012-03-16 12:28:42 +01:00
|
|
|
|
|
|
|
from django.dispatch import receiver
|
2012-04-14 09:47:34 +02:00
|
|
|
from django.utils.translation import ugettext as _
|
2012-03-16 12:28:42 +01:00
|
|
|
|
2012-04-14 12:52:56 +02:00
|
|
|
from config.models import config
|
2012-03-12 18:22:18 +01:00
|
|
|
|
2012-04-16 16:35:30 +02:00
|
|
|
from openslides.projector.signals import projector_overlays
|
2012-03-16 12:28:42 +01:00
|
|
|
|
|
|
|
|
2012-03-12 18:22:18 +01:00
|
|
|
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):
|
2012-04-14 20:10:49 +02:00
|
|
|
def __init__(self, model_slide=False, func=None, model=None, category=None,
|
2012-04-15 15:46:32 +02:00
|
|
|
key=None, model_name='', control_template='', weight=0, name=''):
|
2012-03-12 18:22:18 +01:00
|
|
|
"""
|
|
|
|
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.
|
2012-04-14 20:10:49 +02:00
|
|
|
key: the key in the slide object to find itself.
|
2012-03-12 18:22:18 +01:00
|
|
|
"""
|
|
|
|
self.model_slide = model_slide
|
|
|
|
self.func = func
|
|
|
|
self.model = model
|
|
|
|
self.model_name = model_name
|
|
|
|
self.category = category
|
|
|
|
self.key = key
|
2012-04-14 20:10:49 +02:00
|
|
|
self.control_template = control_template
|
|
|
|
self.weight = weight
|
2012-04-15 15:46:32 +02:00
|
|
|
self.name = name
|
2012-03-12 18:22:18 +01:00
|
|
|
|
2012-04-18 18:07:24 +02:00
|
|
|
@property
|
|
|
|
def active(self):
|
|
|
|
from api import get_active_slide
|
|
|
|
return get_active_slide(True) == self.key
|
|
|
|
|
2012-03-12 18:22:18 +01:00
|
|
|
def get_items(self):
|
2012-04-14 20:10:49 +02:00
|
|
|
try:
|
|
|
|
return self.model.objects.all()
|
|
|
|
except AttributeError:
|
|
|
|
return 'No Model'
|
2012-03-16 12:28:42 +01:00
|
|
|
|
|
|
|
|
2012-04-16 16:35:30 +02:00
|
|
|
@receiver(projector_overlays, dispatch_uid="projector_countdown")
|
2012-03-16 12:28:42 +01:00
|
|
|
def countdown(sender, **kwargs):
|
2012-04-16 16:35:30 +02:00
|
|
|
name = 'Countdown'
|
2012-04-14 09:47:34 +02:00
|
|
|
if kwargs['register']:
|
|
|
|
return name
|
|
|
|
if name in kwargs['call']:
|
2012-03-16 12:28:42 +01:00
|
|
|
starttime = config['countdown_start']
|
2012-04-14 09:47:34 +02:00
|
|
|
seconds = max(0, int(starttime + config['agenda_countdown_time'] - time()))
|
|
|
|
return (name, seconds)
|
2012-03-16 12:28:42 +01:00
|
|
|
return None
|
2012-04-16 16:35:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
@receiver(projector_overlays, dispatch_uid="projector_message")
|
|
|
|
def projector_message(sender, **kwargs):
|
|
|
|
name = 'Message'
|
|
|
|
if kwargs['register']:
|
|
|
|
return name
|
|
|
|
if name in kwargs['call']:
|
|
|
|
message = config['projector_message']
|
|
|
|
if message != '':
|
|
|
|
return (name, message)
|
|
|
|
return None
|