rewrote widgets for the dashboard
This commit is contained in:
parent
dfb24ba61a
commit
6b7ea558fc
@ -229,7 +229,5 @@ def get_widgets(request):
|
|||||||
template='agenda/widget.html',
|
template='agenda/widget.html',
|
||||||
context={
|
context={
|
||||||
'agenda': SLIDE['agenda'],
|
'agenda': SLIDE['agenda'],
|
||||||
'items': Item.objects.all(),
|
'items': Item.objects.all()},
|
||||||
}
|
permission_required='agenda.can_manage_agenda')]
|
||||||
),
|
|
||||||
]
|
|
||||||
|
@ -917,6 +917,8 @@ def register_tab(request):
|
|||||||
|
|
||||||
def get_widgets(request):
|
def get_widgets(request):
|
||||||
return [
|
return [
|
||||||
Widget(name='applications', template='application/widget.html',
|
Widget(
|
||||||
context={'applications': Application.objects.all()})
|
name='applications',
|
||||||
]
|
template='application/widget.html',
|
||||||
|
context={'applications': Application.objects.all()},
|
||||||
|
permission_required='application.can_manage_application')]
|
||||||
|
@ -657,6 +657,8 @@ def register_tab(request):
|
|||||||
|
|
||||||
def get_widgets(request):
|
def get_widgets(request):
|
||||||
return [
|
return [
|
||||||
Widget(name=_('Assignments'), template='assignment/widget.html',
|
Widget(
|
||||||
context={'assignments': Assignment.objects.all()})
|
name=_('Assignments'),
|
||||||
]
|
template='assignment/widget.html',
|
||||||
|
context={'assignments': Assignment.objects.all()},
|
||||||
|
permission_required='assignment.can_manage_assignment')]
|
||||||
|
@ -106,13 +106,20 @@ class Widget(object):
|
|||||||
Class for a Widget for the Projector-Tab.
|
Class for a Widget for the Projector-Tab.
|
||||||
"""
|
"""
|
||||||
def __init__(self, name, html=None, template=None, context={},
|
def __init__(self, name, html=None, template=None, context={},
|
||||||
permission_required=None):
|
permission_required=None, display_name=None, default_column=1):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
if display_name is None:
|
||||||
|
self.display_name = name.capitalize()
|
||||||
|
else:
|
||||||
|
self.display_name = display_name
|
||||||
|
|
||||||
if html is not None:
|
if html is not None:
|
||||||
self.html = html
|
self.html = html
|
||||||
elif template is not None:
|
elif template is not None:
|
||||||
self.html = render_to_string(template, context)
|
self.html = render_to_string(template, context)
|
||||||
|
|
||||||
self.permission_required = permission_required
|
self.permission_required = permission_required
|
||||||
|
self.default_column = default_column
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return self.name.lower()
|
return self.name.lower()
|
||||||
@ -121,7 +128,10 @@ class Widget(object):
|
|||||||
return self.html
|
return self.html
|
||||||
|
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
return self.name.capitalize()
|
return self.display_name
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return self.get_name()
|
||||||
|
|
||||||
|
|
||||||
@receiver(projector_overlays, dispatch_uid="projector_countdown")
|
@receiver(projector_overlays, dispatch_uid="projector_countdown")
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{% load staticfiles %}
|
{% load staticfiles %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load tags %}
|
{% load tags %}
|
||||||
|
|
||||||
<form id="overlay_message" action="" method="post" style="display:inline">{% csrf_token %}
|
<form id="overlay_message" action="" 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' %}">
|
<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'>
|
<button type="submit" class="button" name='message'>
|
||||||
|
@ -15,24 +15,31 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{% trans 'Dashboard' %}</h1>
|
<h1>{% trans 'Dashboard' %}</h1>
|
||||||
|
{% if perms.projector.can_manage_projector %}
|
||||||
<div style="text-align: right; padding: 0 10px 5px 0; margin-top:-20px;">
|
<div style="text-align: right; padding: 0 10px 5px 0; margin-top:-20px;">
|
||||||
<!-- projector control -->
|
<!-- projector control -->
|
||||||
{% trans "Adjust projector view" %}:
|
{% trans "Adjust projector view" %}:
|
||||||
<a class="projector_edit" href="{% url projector_bigger %}" title="{% trans 'Zoom in' %}">
|
<a class="projector_edit" href="{% url projector_bigger %}" title="{% trans 'Zoom in' %}">
|
||||||
<img src="{% static 'images/icons/zoom-in.png' %}" /></a>
|
<img src="{% static 'images/icons/zoom-in.png' %}" />
|
||||||
|
</a>
|
||||||
<a class="projector_edit" href="{% url projector_smaller %}" title="{% trans 'Zoom out' %}">
|
<a class="projector_edit" href="{% url projector_smaller %}" title="{% trans 'Zoom out' %}">
|
||||||
<img src="{% static 'images/icons/zoom-out.png' %}" /></a>
|
<img src="{% static 'images/icons/zoom-out.png' %}" />
|
||||||
|
</a>
|
||||||
<a class="projector_edit" href="{% url projector_up %}" title="{% trans 'Scroll text up' %}">
|
<a class="projector_edit" href="{% url projector_up %}" title="{% trans 'Scroll text up' %}">
|
||||||
<img src="{% static 'images/icons/go-up.png' %}" /></a>
|
<img src="{% static 'images/icons/go-up.png' %}" />
|
||||||
|
</a>
|
||||||
<a class="projector_edit" href="{% url projector_down %}" title="{% trans 'Scroll text down' %}">
|
<a class="projector_edit" href="{% url projector_down %}" title="{% trans 'Scroll text down' %}">
|
||||||
<img src="{% static 'images/icons/go-down.png' %}" /></a>
|
<img src="{% static 'images/icons/go-down.png' %}" />
|
||||||
|
</a>
|
||||||
<a class="projector_edit" href="{% url projector_clean %}" title="{% trans 'Reset projector view' %}">
|
<a class="projector_edit" href="{% url projector_clean %}" title="{% trans 'Reset projector view' %}">
|
||||||
<img src="{% static 'images/icons/view-reset.png' %}" /></a>
|
<img src="{% static 'images/icons/view-reset.png' %}" />
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="column" id="col1">
|
<div class="column" id="col1">
|
||||||
{% for name, widget in widgets.items %}
|
{% for name, widget in widgets.items %}
|
||||||
{% if name != 'projector' %}
|
{% if widget.default_column == 1 %}
|
||||||
<div class="portlet" id="portlet_{{ widget.get_name }}">
|
<div class="portlet" id="portlet_{{ widget.get_name }}">
|
||||||
<div class="portlet-header">{% trans widget.get_title %}</div>
|
<div class="portlet-header">{% trans widget.get_title %}</div>
|
||||||
<div class="portlet-content">
|
<div class="portlet-content">
|
||||||
@ -44,58 +51,15 @@
|
|||||||
</div> <!-- end column-->
|
</div> <!-- end column-->
|
||||||
|
|
||||||
<div class="column" id="col2">
|
<div class="column" id="col2">
|
||||||
<!-- Projector Live View -->
|
{% for name, widget in widgets.items %}
|
||||||
<div class="portlet" id="portlet_liveview">
|
{% if widget.default_column == 2 %}
|
||||||
<div class="portlet-header">
|
<div class="portlet" id="portlet_{{ widget.get_name }}">
|
||||||
{% trans "Projector Live View" %}
|
<div class="portlet-header">{% trans widget.get_title %}</div>
|
||||||
</div>
|
|
||||||
<div class="portlet-content">
|
|
||||||
<a href="{% url projector_show %}" target="_blank" title="{% trans 'Open Projector view' %}" >
|
|
||||||
<div id="iframewrapper">
|
|
||||||
<iframe id="iframe" src="{% url projector_show %}" frameborder="0"></iframe>
|
|
||||||
<div id="iframeoverlay"></div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div> <!-- end portlet-->
|
|
||||||
|
|
||||||
<!-- Overlays (Countdown etc.)-->
|
|
||||||
<div class="portlet" id="portlet_overlays">
|
|
||||||
<div class="portlet-header">{% trans 'Overlays' %}</div>
|
|
||||||
<div class="portlet-content">
|
|
||||||
<ul>
|
|
||||||
{% for overlay in overlays %}
|
|
||||||
<li>
|
|
||||||
<a id="{{ overlay.def_name }}_inactive" href="{% url projector_overlay_activate overlay.def_name %}" class="overlay"{% if overlay.active %} style="display:none"{% endif %}>
|
|
||||||
<div></div>
|
|
||||||
</a>
|
|
||||||
<a id="{{ overlay.def_name }}_active" href="{% url projector_overlay_deactivate overlay.def_name %}" class="overlay active"{% if not overlay.active %} style="display:none"{% endif %}>
|
|
||||||
<div></div>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
{{ overlay }}:
|
|
||||||
{# TODO: Call the html via overlay.html #}
|
|
||||||
{# Countdown #}
|
|
||||||
{% if overlay.def_name == "Countdown" %}
|
|
||||||
{% include 'projector/control_countdown.html' %}
|
|
||||||
{% endif %}
|
|
||||||
{% if overlay.def_name == "Message" %}
|
|
||||||
{% include 'projector/control_overlay_message.html' %}
|
|
||||||
{% endif %}
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div> <!-- end portlet-->
|
|
||||||
|
|
||||||
<!-- Custom slides -->
|
|
||||||
{% with widget=widgets.projector %}
|
|
||||||
<div class="portlet" id="portlet_customslides">
|
|
||||||
<div class="portlet-header">{% trans "Custom slides" %}</div>
|
|
||||||
<div class="portlet-content">
|
<div class="portlet-content">
|
||||||
{{ widget.html }}
|
{{ widget.html }}
|
||||||
</div>
|
</div>
|
||||||
</div> <!-- end portlet-->
|
</div>
|
||||||
{% endwith %}
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
</div> <!-- end column -->
|
</div> <!-- end column -->
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
{% load i18n %}
|
||||||
|
{% load tags %}
|
||||||
|
|
||||||
|
|
||||||
|
<a href="{% url projector_show %}" target="_blank">
|
||||||
|
<div id="iframewrapper">
|
||||||
|
<iframe id="iframe" src="{% url projector_show %}" frameborder="0"></iframe>
|
||||||
|
<div id="iframeoverlay"></div>
|
||||||
|
</div>
|
||||||
|
</a>
|
24
openslides/projector/templates/projector/overlay_widget.html
Normal file
24
openslides/projector/templates/projector/overlay_widget.html
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{% load i18n %}
|
||||||
|
{% load tags %}
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{% for overlay in overlays %}
|
||||||
|
<li>
|
||||||
|
<a id="{{ overlay.def_name }}_inactive" href="{% url projector_overlay_activate overlay.def_name %}" class="overlay"{% if overlay.active %} style="display:none"{% endif %}>
|
||||||
|
<div></div>
|
||||||
|
</a>
|
||||||
|
<a id="{{ overlay.def_name }}_active" href="{% url projector_overlay_deactivate overlay.def_name %}" class="overlay active"{% if not overlay.active %} style="display:none"{% endif %}>
|
||||||
|
<div></div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{{ overlay }}:
|
||||||
|
{# TODO: Call the html via overlay.html #}
|
||||||
|
{% if overlay.def_name == "Countdown" %}
|
||||||
|
{% include 'projector/control_countdown.html' %}
|
||||||
|
{% endif %}
|
||||||
|
{% if overlay.def_name == "Message" %}
|
||||||
|
{% include 'projector/control_overlay_message.html' %}
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
@ -43,22 +43,8 @@ class DashboardView(TemplateView, AjaxMixin):
|
|||||||
template_name = 'projector/dashboard.html'
|
template_name = 'projector/dashboard.html'
|
||||||
permission_required = 'projector.can_see_dashboard'
|
permission_required = 'projector.can_see_dashboard'
|
||||||
|
|
||||||
def get_projector_overlays(self):
|
|
||||||
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:
|
|
||||||
projector_overlay = ProjectorOverlay(def_name=name,
|
|
||||||
active=False)
|
|
||||||
projector_overlay.save()
|
|
||||||
overlays.append(projector_overlay)
|
|
||||||
return overlays
|
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
|
# TODO: Try to put this code in the widget
|
||||||
if 'message' in request.POST:
|
if 'message' in request.POST:
|
||||||
projector_message_set(request.POST['message_text'])
|
projector_message_set(request.POST['message_text'])
|
||||||
elif 'message-clean' in request.POST:
|
elif 'message-clean' in request.POST:
|
||||||
@ -88,16 +74,13 @@ class DashboardView(TemplateView, AjaxMixin):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
for widget in modul_widgets:
|
for widget in modul_widgets:
|
||||||
if self.request.user.has_perm(widget.permission_required):
|
if (widget.permission_required is None or
|
||||||
|
self.request.user.has_perm(widget.permission_required)):
|
||||||
widgets[widget.get_name()] = widget
|
widgets[widget.get_name()] = widget
|
||||||
|
print widget, widget.permission_required
|
||||||
|
|
||||||
|
|
||||||
context.update({
|
context['widgets'] = widgets
|
||||||
'countdown_time': config['countdown_time'],
|
|
||||||
'countdown_state' : config['countdown_state'],
|
|
||||||
'overlays': self.get_projector_overlays(),
|
|
||||||
'widgets': widgets,
|
|
||||||
})
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
@ -350,15 +333,51 @@ def register_tab(request):
|
|||||||
|
|
||||||
def get_widgets(request):
|
def get_widgets(request):
|
||||||
"""
|
"""
|
||||||
Return the custom slide widget.
|
Return the widgets of the projector app
|
||||||
"""
|
"""
|
||||||
return [
|
widgets = []
|
||||||
Widget(
|
|
||||||
name='projector',
|
# Projector live view widget
|
||||||
template='projector/widget.html',
|
widgets.append(Widget(
|
||||||
|
name='live_view',
|
||||||
|
display_name=_('Projector live view'),
|
||||||
|
template='projector/live_view_widget.html',
|
||||||
|
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:
|
||||||
|
projector_overlay = ProjectorOverlay(def_name=name,
|
||||||
|
active=False)
|
||||||
|
projector_overlay.save()
|
||||||
|
overlays.append(projector_overlay)
|
||||||
|
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']}))
|
||||||
|
|
||||||
|
# Custom slide widget
|
||||||
|
widgets.append(Widget(
|
||||||
|
name='custom_slide',
|
||||||
|
display_name=_('Custom Slide'),
|
||||||
|
template='projector/custom_slide_widget.html',
|
||||||
context={
|
context={
|
||||||
'slides': ProjectorSlide.objects.all(),
|
'slides': ProjectorSlide.objects.all(),
|
||||||
'welcomepage_is_active': not bool(config["presentation"])},
|
'welcomepage_is_active': not bool(config["presentation"])},
|
||||||
permission_required = 'projector.can_manage_projector',
|
permission_required='projector.can_manage_projector',
|
||||||
),
|
default_column=2))
|
||||||
]
|
|
||||||
|
return widgets
|
||||||
|
Loading…
Reference in New Issue
Block a user