send overlay message data to own view
This commit is contained in:
parent
705fb972b1
commit
423f04d0be
@ -165,7 +165,6 @@ def get_all_widgets(request, session=False):
|
||||
continue
|
||||
|
||||
for widget in modul_widgets:
|
||||
print widget, session_widgets.get(widget, True)
|
||||
if (widget.permission_required is None or
|
||||
request.user.has_perm(widget.permission_required)):
|
||||
if not session or session_widgets.get(widget.get_name(), True):
|
||||
|
@ -2,7 +2,7 @@
|
||||
{% load i18n %}
|
||||
{% load tags %}
|
||||
|
||||
<form id="overlay_message" action="" method="post" style="display:inline">{% csrf_token %}
|
||||
<form id="overlay_message" action="{% url projector_overlay_message %}" method="post" style="display:inline">{% csrf_token %}
|
||||
<input id="overlay_message_text" name='message_text' type='text' style='width: 40%' value="{% get_config 'projector_message' %}">
|
||||
<button type="submit" class="button" name='message'>
|
||||
<span class="icon ok">{% trans 'Apply' %}</span>
|
||||
|
@ -14,7 +14,8 @@ from django.conf.urls.defaults import patterns, url
|
||||
|
||||
from openslides.projector.views import (DashboardView, ActivateView,
|
||||
CustomSlideCreateView, CustomSlideUpdateView, CustomSlideDeleteView,
|
||||
CountdownEdit, ProjectorEdit, Projector, ActivateOverlay, SelectWidgetsView)
|
||||
CountdownEdit, ProjectorEdit, Projector, ActivateOverlay, SelectWidgetsView,
|
||||
OverlayMessageView)
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
@ -61,6 +62,11 @@ urlpatterns = patterns('',
|
||||
name='projector_select_widgets',
|
||||
),
|
||||
|
||||
url(r'^overlay_message/$',
|
||||
OverlayMessageView.as_view(),
|
||||
name='projector_overlay_message',
|
||||
),
|
||||
|
||||
url(r'^new/$',
|
||||
CustomSlideCreateView.as_view(),
|
||||
name='customslide_new',
|
||||
|
@ -15,6 +15,7 @@ from time import time
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.core.context_processors import csrf
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import transaction
|
||||
from django.db.models import Q
|
||||
@ -46,21 +47,6 @@ class DashboardView(TemplateView, AjaxMixin):
|
||||
template_name = 'projector/dashboard.html'
|
||||
permission_required = 'projector.can_see_dashboard'
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
# TODO: Try to put this code in the widget
|
||||
if 'message' in request.POST:
|
||||
projector_message_set(request.POST['message_text'])
|
||||
elif 'message-clean' in request.POST:
|
||||
projector_message_delete()
|
||||
if request.is_ajax():
|
||||
return self.ajax_get(request, *args, **kwargs)
|
||||
return self.get(request, *args, **kwargs)
|
||||
|
||||
def get_ajax_context(self, **kwargs):
|
||||
return {
|
||||
'overlay_message': config['projector_message'],
|
||||
}
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(DashboardView, self).get_context_data(**kwargs)
|
||||
|
||||
@ -279,6 +265,28 @@ class CountdownEdit(RedirectView):
|
||||
}
|
||||
|
||||
|
||||
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):
|
||||
return {
|
||||
'overlay_message': config['projector_message'],
|
||||
}
|
||||
|
||||
|
||||
|
||||
class ActivateOverlay(RedirectView):
|
||||
"""
|
||||
Activate or deactivate an overlay.
|
||||
@ -384,25 +392,30 @@ def get_widgets(request):
|
||||
active=False)
|
||||
projector_overlay.save()
|
||||
overlays.append(projector_overlay)
|
||||
|
||||
context = {
|
||||
'overlays':overlays,
|
||||
'countdown_time': config['countdown_time'],
|
||||
'countdown_state' : config['countdown_state']}
|
||||
context.update(csrf(request))
|
||||
widgets.append(Widget(
|
||||
name='overlays',
|
||||
display_name=_('Manage Overlays'),
|
||||
template='projector/overlay_widget.html',
|
||||
permission_required='projector.can_manage_projector',
|
||||
default_column=2,
|
||||
context={
|
||||
'overlays':overlays,
|
||||
'countdown_time': config['countdown_time'],
|
||||
'countdown_state' : config['countdown_state']}))
|
||||
context=context))
|
||||
|
||||
|
||||
# Custom slide widget
|
||||
context = {
|
||||
'slides': ProjectorSlide.objects.all(),
|
||||
'welcomepage_is_active': not bool(config["presentation"])}
|
||||
widgets.append(Widget(
|
||||
name='custom_slide',
|
||||
display_name=_('Custom Slide'),
|
||||
template='projector/custom_slide_widget.html',
|
||||
context={
|
||||
'slides': ProjectorSlide.objects.all(),
|
||||
'welcomepage_is_active': not bool(config["presentation"])},
|
||||
context=context,
|
||||
permission_required='projector.can_manage_projector',
|
||||
default_column=2))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user