2012-02-03 20:49:16 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
2012-02-06 22:08:08 +01:00
|
|
|
openslides.projector.views
|
2012-07-07 14:01:40 +02:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2012-02-03 20:49:16 +01:00
|
|
|
|
2012-02-06 22:08:08 +01:00
|
|
|
Views for the projector app.
|
2012-02-03 20:49:16 +01:00
|
|
|
|
2012-04-25 22:29:19 +02:00
|
|
|
:copyright: 2011, 2012 by OpenSlides team, see AUTHORS.
|
2012-02-03 20:49:16 +01:00
|
|
|
:license: GNU GPL, see LICENSE for more details.
|
|
|
|
"""
|
2012-04-25 22:29:19 +02:00
|
|
|
|
2012-02-03 20:49:16 +01:00
|
|
|
from datetime import datetime
|
2012-04-14 09:47:34 +02:00
|
|
|
from time import time
|
2012-02-03 20:49:16 +01:00
|
|
|
|
2012-05-18 23:07:09 +02:00
|
|
|
from django.contrib import messages
|
2012-10-25 15:17:25 +02:00
|
|
|
from django.core.cache import cache
|
2012-08-15 18:00:22 +02:00
|
|
|
from django.core.context_processors import csrf
|
2012-02-03 20:49:16 +01:00
|
|
|
from django.core.urlresolvers import reverse
|
2012-08-15 13:42:25 +02:00
|
|
|
from django.db import transaction
|
2012-07-07 14:01:40 +02:00
|
|
|
from django.db.models import Q
|
2012-11-08 20:08:09 +01:00
|
|
|
from django.shortcuts import redirect
|
2012-11-17 20:59:30 +01:00
|
|
|
from django.template import RequestContext
|
2012-07-10 01:33:03 +02:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2012-02-03 20:49:16 +01:00
|
|
|
|
2012-07-07 14:01:40 +02:00
|
|
|
from openslides.utils.template import render_block_to_string, Tab
|
2012-11-24 14:01:21 +01:00
|
|
|
from openslides.utils.views import (
|
|
|
|
TemplateView, RedirectView, CreateView, UpdateView, DeleteView, AjaxMixin)
|
2012-07-01 15:35:05 +02:00
|
|
|
from openslides.config.models import config
|
2012-11-24 14:01:21 +01:00
|
|
|
from .api import (
|
|
|
|
get_active_slide, set_active_slide, projector_message_set,
|
|
|
|
projector_message_delete, get_slide_from_sid, get_all_widgets,
|
|
|
|
clear_projector_cache)
|
|
|
|
from .forms import SelectWidgetsForm
|
|
|
|
from .models import ProjectorOverlay, ProjectorSlide
|
|
|
|
from .projector import Widget
|
|
|
|
from .signals import projector_overlays
|
2012-03-03 09:11:56 +01:00
|
|
|
|
|
|
|
|
2012-08-15 10:58:29 +02:00
|
|
|
class DashboardView(TemplateView, AjaxMixin):
|
2012-07-07 14:01:40 +02:00
|
|
|
"""
|
|
|
|
Overview over all possible slides, the overlays and a liveview.
|
|
|
|
"""
|
2012-08-15 10:58:29 +02:00
|
|
|
template_name = 'projector/dashboard.html'
|
|
|
|
permission_required = 'projector.can_see_dashboard'
|
2012-03-03 09:11:56 +01:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
2012-08-15 10:58:29 +02:00
|
|
|
context = super(DashboardView, self).get_context_data(**kwargs)
|
2012-06-11 13:43:48 +02:00
|
|
|
|
2012-08-15 13:42:25 +02:00
|
|
|
context['widgets'] = get_all_widgets(self.request, session=True)
|
2012-03-03 09:11:56 +01:00
|
|
|
return context
|
|
|
|
|
|
|
|
|
2012-07-01 15:35:05 +02:00
|
|
|
class Projector(TemplateView, AjaxMixin):
|
2012-07-07 14:01:40 +02:00
|
|
|
"""
|
|
|
|
The Projector-Page.
|
|
|
|
"""
|
2012-07-01 15:35:05 +02:00
|
|
|
permission_required = 'projector.can_see_projector'
|
|
|
|
|
|
|
|
@property
|
|
|
|
def data(self):
|
2012-04-18 15:47:51 +02:00
|
|
|
try:
|
2012-07-01 15:35:05 +02:00
|
|
|
return self._data
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
sid = self.kwargs['sid']
|
|
|
|
if sid is None:
|
|
|
|
try:
|
|
|
|
data = get_active_slide()
|
2012-11-24 14:01:21 +01:00
|
|
|
except AttributeError: # TODO: It has to be an Slide.DoesNotExist
|
2012-07-01 15:35:05 +02:00
|
|
|
data = None
|
|
|
|
ajax = 'on'
|
2012-09-20 09:55:27 +02:00
|
|
|
active_sid = get_active_slide(True)
|
2012-07-01 15:35:05 +02:00
|
|
|
else:
|
|
|
|
data = get_slide_from_sid(sid)
|
|
|
|
ajax = 'off'
|
|
|
|
|
|
|
|
if data is None:
|
|
|
|
data = {
|
|
|
|
'title': config['event_name'],
|
|
|
|
'template': 'projector/default.html',
|
|
|
|
}
|
|
|
|
data['overlays'] = []
|
|
|
|
data['ajax'] = ajax
|
|
|
|
|
|
|
|
# Projector Overlays
|
|
|
|
if self.kwargs['sid'] is None:
|
2012-07-07 14:01:40 +02:00
|
|
|
active_defs = ProjectorOverlay.objects.filter(active=True) \
|
2012-11-24 14:01:21 +01:00
|
|
|
.filter(Q(sid=active_sid) | Q(sid=None)).values_list(
|
|
|
|
'def_name', flat=True)
|
|
|
|
for receiver, response in projector_overlays.send(
|
|
|
|
sender=sid, register=False, call=active_defs):
|
2012-07-01 15:35:05 +02:00
|
|
|
if response is not None:
|
|
|
|
data['overlays'].append(response)
|
|
|
|
self._data = data
|
|
|
|
return data
|
|
|
|
|
|
|
|
def get_template_names(self):
|
|
|
|
return [self.data['template']]
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super(Projector, self).get_context_data(**kwargs)
|
|
|
|
context.update(self.data)
|
|
|
|
return context
|
|
|
|
|
|
|
|
def get_ajax_context(self, **kwargs):
|
2013-01-08 20:40:27 +01:00
|
|
|
language = self.request.LANGUAGE_CODE
|
|
|
|
content = cache.get('projector_content_' + language)
|
2012-10-25 15:17:25 +02:00
|
|
|
if not content:
|
|
|
|
content = render_block_to_string(
|
|
|
|
self.get_template_names()[0],
|
|
|
|
'content', self.data)
|
2013-01-08 20:40:27 +01:00
|
|
|
cache.set('projector_content_' + language, content, 1)
|
2012-10-25 15:17:25 +02:00
|
|
|
|
|
|
|
scrollcontent = cache.get('projector_scrollcontent')
|
|
|
|
if not scrollcontent:
|
|
|
|
scrollcontent = render_block_to_string(
|
|
|
|
self.get_template_names()[0],
|
|
|
|
'scrollcontent', self.data)
|
2013-01-08 20:40:27 +01:00
|
|
|
cache.set('projector_scrollcontent_' + language, scrollcontent, 1)
|
2012-07-01 15:35:05 +02:00
|
|
|
|
2012-10-29 23:26:10 +01:00
|
|
|
# TODO: do not call the hole data-methode, if we only need some vars
|
2013-01-08 20:40:27 +01:00
|
|
|
data = cache.get('projector_data_' + language)
|
2012-10-29 23:26:10 +01:00
|
|
|
if not data:
|
|
|
|
data = self.data
|
2013-01-08 20:40:27 +01:00
|
|
|
cache.set('projector_data_' + language, data)
|
2012-10-30 23:45:06 +01:00
|
|
|
# clear cache if countdown is enabled
|
|
|
|
if config['countdown_state'] == 'active':
|
|
|
|
clear_projector_cache()
|
2012-07-01 15:35:05 +02:00
|
|
|
context = super(Projector, self).get_ajax_context(**kwargs)
|
2012-07-04 15:00:08 +02:00
|
|
|
content_hash = hash(content)
|
2012-07-01 15:35:05 +02:00
|
|
|
context.update({
|
2012-02-03 23:12:28 +01:00
|
|
|
'content': content,
|
2012-04-24 22:27:16 +02:00
|
|
|
'scrollcontent': scrollcontent,
|
2012-02-03 23:12:28 +01:00
|
|
|
'time': datetime.now().strftime('%H:%M'),
|
2012-10-29 23:26:10 +01:00
|
|
|
'overlays': data['overlays'],
|
|
|
|
'title': data['title'],
|
2012-02-15 12:04:11 +01:00
|
|
|
'bigger': config['bigger'],
|
|
|
|
'up': config['up'],
|
2012-07-04 15:00:08 +02:00
|
|
|
'content_hash': content_hash,
|
2012-07-01 15:35:05 +02:00
|
|
|
})
|
|
|
|
return context
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
|
|
if request.is_ajax():
|
|
|
|
return self.ajax_get(request, *args, **kwargs)
|
|
|
|
return super(Projector, self).get(request, *args, **kwargs)
|
|
|
|
|
2012-02-03 20:49:16 +01:00
|
|
|
|
2012-07-07 14:01:40 +02:00
|
|
|
class ActivateView(RedirectView):
|
|
|
|
"""
|
|
|
|
Activate a Slide.
|
|
|
|
"""
|
|
|
|
permission_required = 'projector.can_manage_projector'
|
2012-08-15 10:58:29 +02:00
|
|
|
url = 'dashboard'
|
2012-07-07 14:01:40 +02:00
|
|
|
allow_ajax = True
|
|
|
|
|
|
|
|
def pre_redirect(self, request, *args, **kwargs):
|
|
|
|
try:
|
|
|
|
set_active_slide(kwargs['sid'], kwargs['argument'])
|
|
|
|
except KeyError:
|
|
|
|
set_active_slide(kwargs['sid'])
|
|
|
|
config['up'] = 0
|
|
|
|
config['bigger'] = 100
|
|
|
|
|
2012-02-03 20:49:16 +01:00
|
|
|
|
2012-08-15 13:42:25 +02:00
|
|
|
class SelectWidgetsView(TemplateView):
|
|
|
|
"""
|
|
|
|
Show a Form to Select the widgets.
|
|
|
|
"""
|
|
|
|
permission_required = 'projector.can_see_dashboard'
|
|
|
|
template_name = 'projector/select_widgets.html'
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super(SelectWidgetsView, self). get_context_data(**kwargs)
|
|
|
|
widgets = get_all_widgets(self.request)
|
|
|
|
activated_widgets = self.request.session.get('widgets', {})
|
|
|
|
for name, widget in widgets.items():
|
|
|
|
initial = {'widget': activated_widgets.get(name, True)}
|
|
|
|
if self.request.method == 'POST':
|
|
|
|
widget.form = SelectWidgetsForm(self.request.POST, prefix=name,
|
|
|
|
initial=initial)
|
|
|
|
else:
|
|
|
|
widget.form = SelectWidgetsForm(prefix=name, initial=initial)
|
|
|
|
|
|
|
|
context['widgets'] = widgets
|
|
|
|
return context
|
|
|
|
|
|
|
|
@transaction.commit_manually
|
|
|
|
def post(self, request, *args, **kwargs):
|
|
|
|
context = self.get_context_data(**kwargs)
|
|
|
|
activated_widgets = self.request.session.get('widgets', {})
|
|
|
|
|
|
|
|
transaction.commit()
|
|
|
|
for name, widget in context['widgets'].items():
|
|
|
|
if widget.form.is_valid():
|
|
|
|
activated_widgets[name] = widget.form.cleaned_data['widget']
|
|
|
|
else:
|
|
|
|
transaction.rollback()
|
|
|
|
messages.error(request, _('Errors in the form'))
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
transaction.commit()
|
|
|
|
self.request.session['widgets'] = activated_widgets
|
2012-11-08 20:08:09 +01:00
|
|
|
return redirect(reverse('dashboard'))
|
2012-08-15 13:42:25 +02:00
|
|
|
|
|
|
|
|
2012-07-01 10:52:08 +02:00
|
|
|
class ProjectorEdit(RedirectView):
|
2012-07-07 14:01:40 +02:00
|
|
|
"""
|
|
|
|
Scale or scroll the projector.
|
|
|
|
"""
|
2012-07-01 10:52:08 +02:00
|
|
|
permission_required = 'projector.can_manage_projector'
|
2012-08-15 10:58:29 +02:00
|
|
|
url = 'dashboard'
|
2012-07-01 10:52:08 +02:00
|
|
|
allow_ajax = True
|
2012-02-03 20:49:16 +01:00
|
|
|
|
2012-07-01 10:52:08 +02:00
|
|
|
def pre_redirect(self, request, *args, **kwargs):
|
|
|
|
direction = kwargs['direction']
|
|
|
|
if direction == 'bigger':
|
|
|
|
config['bigger'] = int(config['bigger']) + 20
|
|
|
|
elif direction == 'smaller':
|
|
|
|
config['bigger'] = int(config['bigger']) - 20
|
|
|
|
elif direction == 'up':
|
|
|
|
config['up'] = int(config['up']) - 10
|
|
|
|
elif direction == 'down':
|
|
|
|
if config['up'] < 0:
|
|
|
|
config['up'] = int(config['up']) + 10
|
|
|
|
elif direction == 'clean':
|
|
|
|
config['up'] = 0
|
|
|
|
config['bigger'] = 100
|
2012-02-03 20:49:16 +01:00
|
|
|
|
|
|
|
|
2012-07-01 10:44:41 +02:00
|
|
|
class CountdownEdit(RedirectView):
|
2012-07-07 14:01:40 +02:00
|
|
|
"""
|
|
|
|
Start, stop or reset the countdown.
|
|
|
|
"""
|
2012-07-01 10:44:41 +02:00
|
|
|
permission_required = 'projector.can_manage_projector'
|
2012-08-15 10:58:29 +02:00
|
|
|
url = 'dashboard'
|
2012-07-01 10:44:41 +02:00
|
|
|
allow_ajax = True
|
|
|
|
|
|
|
|
def pre_redirect(self, request, *args, **kwargs):
|
2012-07-01 10:52:08 +02:00
|
|
|
command = kwargs['command']
|
2012-07-04 02:43:26 +02:00
|
|
|
# countdown_state is one of 'inactive', 'paused' and 'active', 'expired'
|
2012-07-01 10:44:41 +02:00
|
|
|
if command in ['reset', 'start', 'stop']:
|
|
|
|
config['countdown_time'] = config['countdown_time']
|
2012-04-25 17:17:24 +02:00
|
|
|
|
|
|
|
if command == 'reset':
|
|
|
|
config['countdown_start_stamp'] = time()
|
|
|
|
config['countdown_pause_stamp'] = 0
|
|
|
|
config['countdown_state'] = 'inactive'
|
2012-07-01 10:44:41 +02:00
|
|
|
elif command == 'start':
|
2012-04-25 17:17:24 +02:00
|
|
|
# if we had stopped the countdown resume were we left of
|
|
|
|
if config['countdown_state'] == 'paused':
|
2012-07-01 10:44:41 +02:00
|
|
|
start_stamp = config['countdown_start_stamp']
|
|
|
|
pause_stamp = config['countdown_pause_stamp']
|
|
|
|
now = time()
|
2012-07-07 14:01:40 +02:00
|
|
|
config['countdown_start_stamp'] = now - \
|
|
|
|
(pause_stamp - start_stamp)
|
2012-04-25 17:17:24 +02:00
|
|
|
else:
|
|
|
|
config['countdown_start_stamp'] = time()
|
|
|
|
|
|
|
|
config['countdown_state'] = 'active'
|
|
|
|
config['countdown_pause_stamp'] = 0
|
2012-07-01 10:44:41 +02:00
|
|
|
elif command == 'stop':
|
|
|
|
if config['countdown_state'] == 'active':
|
|
|
|
config['countdown_pause_stamp'] = time()
|
|
|
|
config['countdown_state'] = 'paused'
|
|
|
|
elif command == 'set-default':
|
|
|
|
try:
|
2012-07-07 14:01:40 +02:00
|
|
|
config['countdown_time'] = \
|
|
|
|
int(self.request.GET['countdown_time'])
|
2012-07-01 10:44:41 +02:00
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
2012-03-18 17:11:58 +01:00
|
|
|
|
2012-07-04 02:43:26 +02:00
|
|
|
def get_ajax_context(self, **kwargs):
|
2012-10-30 23:45:06 +01:00
|
|
|
clear_projector_cache()
|
2012-07-04 02:43:26 +02:00
|
|
|
return {
|
|
|
|
'state': config['countdown_state'],
|
|
|
|
'countdown_time': config['countdown_time'],
|
|
|
|
}
|
|
|
|
|
2012-03-18 17:11:58 +01:00
|
|
|
|
2012-08-15 18:00:22 +02:00
|
|
|
class OverlayMessageView(RedirectView):
|
|
|
|
"""
|
|
|
|
Sets or clears the overlay message
|
|
|
|
"""
|
|
|
|
url = 'dashboard'
|
|
|
|
allow_ajax = True
|
|
|
|
permission_required = 'projector.can_manage_projector'
|
|
|
|
|
|
|
|
def pre_post_redirect(self, request, *args, **kwargs):
|
|
|
|
if 'message' in request.POST:
|
|
|
|
projector_message_set(request.POST['message_text'])
|
|
|
|
elif 'message-clean' in request.POST:
|
|
|
|
projector_message_delete()
|
|
|
|
|
|
|
|
def get_ajax_context(self, **kwargs):
|
2012-10-30 23:45:06 +01:00
|
|
|
clear_projector_cache()
|
2012-08-15 18:00:22 +02:00
|
|
|
return {
|
|
|
|
'overlay_message': config['projector_message'],
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-07 14:01:40 +02:00
|
|
|
class ActivateOverlay(RedirectView):
|
|
|
|
"""
|
|
|
|
Activate or deactivate an overlay.
|
|
|
|
"""
|
2012-08-15 10:58:29 +02:00
|
|
|
url = 'dashboard'
|
2012-07-07 14:01:40 +02:00
|
|
|
allow_ajax = True
|
|
|
|
permission_required = 'projector.can_manage_projector'
|
|
|
|
|
|
|
|
@property
|
|
|
|
def overlay(self):
|
|
|
|
try:
|
|
|
|
return self._overlay
|
|
|
|
except AttributeError:
|
|
|
|
self._overlay = ProjectorOverlay.objects.get(
|
|
|
|
def_name=self.kwargs['name'])
|
|
|
|
return self._overlay
|
|
|
|
|
|
|
|
def pre_redirect(self, request, *args, **kwargs):
|
|
|
|
if kwargs['activate']:
|
|
|
|
self.overlay.active = True
|
|
|
|
else:
|
|
|
|
self.overlay.active = False
|
|
|
|
self.overlay.save()
|
|
|
|
|
|
|
|
def get_ajax_context(self, **kwargs):
|
2012-10-30 23:45:06 +01:00
|
|
|
clear_projector_cache()
|
2012-07-07 14:01:40 +02:00
|
|
|
return {
|
|
|
|
'active': self.overlay.active,
|
|
|
|
'def_name': self.overlay.def_name,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class CustomSlideCreateView(CreateView):
|
|
|
|
"""
|
|
|
|
Create a custom slide.
|
|
|
|
"""
|
|
|
|
permission_required = 'agenda.can_manage_agenda'
|
|
|
|
template_name = 'projector/new.html'
|
|
|
|
model = ProjectorSlide
|
|
|
|
context_object_name = 'customslide'
|
2012-08-15 10:58:29 +02:00
|
|
|
success_url = 'dashboard'
|
2012-07-07 14:01:40 +02:00
|
|
|
apply_url = 'customslide_edit'
|
|
|
|
|
|
|
|
|
|
|
|
class CustomSlideUpdateView(UpdateView):
|
|
|
|
"""
|
|
|
|
Update a custom slide.
|
|
|
|
"""
|
|
|
|
permission_required = 'projector.can_manage_projector'
|
|
|
|
template_name = 'projector/new.html'
|
|
|
|
model = ProjectorSlide
|
|
|
|
context_object_name = 'customslide'
|
2012-08-15 10:58:29 +02:00
|
|
|
success_url = 'dashboard'
|
2012-07-07 14:01:40 +02:00
|
|
|
apply_url = 'customslide_edit'
|
|
|
|
|
|
|
|
|
|
|
|
class CustomSlideDeleteView(DeleteView):
|
|
|
|
"""
|
|
|
|
Delete a custom slide.
|
|
|
|
"""
|
|
|
|
permission_required = 'projector.can_manage_projector'
|
|
|
|
model = ProjectorSlide
|
2012-08-15 10:58:29 +02:00
|
|
|
url = 'dashboard'
|
2012-07-07 14:01:40 +02:00
|
|
|
|
|
|
|
|
2012-03-18 17:11:58 +01:00
|
|
|
def register_tab(request):
|
2012-07-07 14:01:40 +02:00
|
|
|
"""
|
|
|
|
Register the projector tab.
|
|
|
|
"""
|
2012-11-24 14:01:21 +01:00
|
|
|
selected = request.path.startswith('/projector/')
|
2012-03-18 17:11:58 +01:00
|
|
|
return Tab(
|
2012-08-15 10:58:29 +02:00
|
|
|
title=_('Dashboard'),
|
|
|
|
url=reverse('dashboard'),
|
2012-11-24 14:01:21 +01:00
|
|
|
permission=request.user.has_perm('projector.can_see_dashboard'),
|
2012-03-18 17:11:58 +01:00
|
|
|
selected=selected,
|
|
|
|
)
|
|
|
|
|
2012-04-14 20:10:49 +02:00
|
|
|
|
2012-06-11 13:43:48 +02:00
|
|
|
def get_widgets(request):
|
2012-07-07 14:01:40 +02:00
|
|
|
"""
|
2012-08-15 11:56:43 +02:00
|
|
|
Return the widgets of the projector app
|
2012-07-07 14:01:40 +02:00
|
|
|
"""
|
2012-08-15 11:56:43 +02:00
|
|
|
widgets = []
|
|
|
|
|
2012-09-20 20:45:37 +02:00
|
|
|
# welcome widget
|
|
|
|
context = {
|
2012-11-17 22:14:49 +01:00
|
|
|
'welcometext': config['welcome_text']}
|
2012-09-20 20:45:37 +02:00
|
|
|
widgets.append(Widget(
|
|
|
|
name='welcome',
|
2012-11-17 22:14:49 +01:00
|
|
|
display_name=config['welcome_title'],
|
2012-09-20 20:45:37 +02:00
|
|
|
template='projector/welcome_widget.html',
|
|
|
|
context=context,
|
|
|
|
permission_required='projector.can_see_dashboard',
|
|
|
|
default_column=1))
|
|
|
|
|
2012-08-15 11:56:43 +02:00
|
|
|
# Projector live view widget
|
|
|
|
widgets.append(Widget(
|
|
|
|
name='live_view',
|
|
|
|
display_name=_('Projector live view'),
|
|
|
|
template='projector/live_view_widget.html',
|
2012-11-24 14:01:21 +01:00
|
|
|
context=RequestContext(request, {}),
|
2012-08-15 11:56:43 +02:00
|
|
|
permission_required='projector.can_see_projector',
|
|
|
|
default_column=2))
|
|
|
|
|
|
|
|
# Overlay Widget
|
|
|
|
overlays = []
|
|
|
|
for receiver, name in projector_overlays.send(sender='registerer',
|
|
|
|
register=True):
|
|
|
|
if name is not None:
|
|
|
|
try:
|
|
|
|
projector_overlay = ProjectorOverlay.objects.get(
|
|
|
|
def_name=name)
|
|
|
|
except ProjectorOverlay.DoesNotExist:
|
2012-11-24 14:01:21 +01:00
|
|
|
projector_overlay = ProjectorOverlay(def_name=name, active=False)
|
2012-08-15 11:56:43 +02:00
|
|
|
projector_overlay.save()
|
|
|
|
overlays.append(projector_overlay)
|
2012-08-15 18:00:22 +02:00
|
|
|
|
|
|
|
context = {
|
2012-11-24 14:01:21 +01:00
|
|
|
'overlays': overlays,
|
|
|
|
'countdown_time': config['countdown_time'],
|
|
|
|
'countdown_state': config['countdown_state']}
|
2012-08-15 18:00:22 +02:00
|
|
|
context.update(csrf(request))
|
2012-08-15 11:56:43 +02:00
|
|
|
widgets.append(Widget(
|
|
|
|
name='overlays',
|
2012-09-11 20:50:53 +02:00
|
|
|
display_name=_('Overlays'),
|
2012-08-15 11:56:43 +02:00
|
|
|
template='projector/overlay_widget.html',
|
|
|
|
permission_required='projector.can_manage_projector',
|
|
|
|
default_column=2,
|
2012-08-15 18:00:22 +02:00
|
|
|
context=context))
|
|
|
|
|
2012-08-15 11:56:43 +02:00
|
|
|
# Custom slide widget
|
2012-08-15 18:00:22 +02:00
|
|
|
context = {
|
2012-09-05 21:54:34 +02:00
|
|
|
'slides': ProjectorSlide.objects.all().order_by('weight'),
|
2012-08-15 18:00:22 +02:00
|
|
|
'welcomepage_is_active': not bool(config["presentation"])}
|
2012-08-15 11:56:43 +02:00
|
|
|
widgets.append(Widget(
|
|
|
|
name='custom_slide',
|
2012-09-05 21:54:34 +02:00
|
|
|
display_name=_('Custom Slides'),
|
2012-08-15 11:56:43 +02:00
|
|
|
template='projector/custom_slide_widget.html',
|
2012-08-15 18:00:22 +02:00
|
|
|
context=context,
|
2012-08-15 11:56:43 +02:00
|
|
|
permission_required='projector.can_manage_projector',
|
|
|
|
default_column=2))
|
|
|
|
|
|
|
|
return widgets
|