2014-01-28 08:32:26 +01:00
|
|
|
from django.utils.translation import ugettext_lazy
|
2013-11-14 01:16:14 +01:00
|
|
|
|
2014-01-28 08:32:26 +01:00
|
|
|
from openslides.config.api import config
|
|
|
|
from openslides.projector.api import get_active_slide
|
2013-11-14 01:16:14 +01:00
|
|
|
from openslides.utils.widgets import Widget
|
|
|
|
|
2014-01-28 08:32:26 +01:00
|
|
|
from .models import CustomSlide
|
|
|
|
|
2013-11-14 01:16:14 +01:00
|
|
|
|
|
|
|
class WelcomeWidget(Widget):
|
|
|
|
"""
|
|
|
|
Welcome widget with static info for all users.
|
|
|
|
"""
|
|
|
|
name = 'welcome'
|
2014-05-15 20:07:09 +02:00
|
|
|
required_permission = 'core.can_see_dashboard'
|
2013-11-14 01:16:14 +01:00
|
|
|
default_column = 1
|
|
|
|
default_weight = 10
|
|
|
|
template_name = 'core/widget_welcome.html'
|
2013-12-09 23:56:01 +01:00
|
|
|
icon_css_class = 'icon-home'
|
2013-11-14 01:16:14 +01:00
|
|
|
|
|
|
|
def get_verbose_name(self):
|
|
|
|
return config['welcome_title']
|
2014-01-28 08:32:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
class CustonSlideWidget(Widget):
|
|
|
|
"""
|
|
|
|
Widget to control custom slides.
|
|
|
|
"""
|
|
|
|
name = 'custom_slide'
|
|
|
|
verbose_name = ugettext_lazy('Custom Slides')
|
2014-05-15 20:07:09 +02:00
|
|
|
required_permission = 'core.can_manage_projector'
|
2014-01-28 08:32:26 +01:00
|
|
|
default_column = 2
|
|
|
|
default_weight = 30
|
|
|
|
template_name = 'core/widget_customslide.html'
|
|
|
|
context = None
|
2014-05-15 14:08:44 +02:00
|
|
|
icon_css_class = 'icon-star'
|
2014-01-28 08:32:26 +01:00
|
|
|
|
|
|
|
def get_context_data(self, **context):
|
2014-11-13 22:23:16 +01:00
|
|
|
"""
|
|
|
|
Adds custom slides and a flag whether the welcome page is active to
|
|
|
|
the context.
|
|
|
|
"""
|
|
|
|
context['slides'] = CustomSlide.objects.all().order_by('weight')
|
|
|
|
context['welcomepage_is_active'] = (
|
|
|
|
get_active_slide().get('callback', 'default') == 'default')
|
|
|
|
return super(CustonSlideWidget, self).get_context_data(**context)
|