rewrite projector_edit view as class based view
This commit is contained in:
parent
2ba1b7e3bc
commit
ea4da31b0c
|
@ -17,7 +17,7 @@ from openslides.utils.views import CreateView
|
||||||
from openslides.projector.models import ProjectorSlide
|
from openslides.projector.models import ProjectorSlide
|
||||||
from openslides.projector.views import (ControlView, ActivateView,
|
from openslides.projector.views import (ControlView, ActivateView,
|
||||||
CustomSlideCreateView, CustomSlideUpdateView, CustomSlideDeleteView,
|
CustomSlideCreateView, CustomSlideUpdateView, CustomSlideDeleteView,
|
||||||
CountdownEdit)
|
CountdownEdit, ProjectorEdit)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,20 +63,35 @@ urlpatterns = patterns('projector.views',
|
||||||
name='customslide_delete',
|
name='customslide_delete',
|
||||||
),
|
),
|
||||||
|
|
||||||
url(r'^bigger/$', 'projector_edit', {'direction': 'bigger'},
|
url(r'^bigger/$',
|
||||||
name='projector_bigger'),
|
ProjectorEdit.as_view(),
|
||||||
|
{'direction': 'bigger'},
|
||||||
|
name='projector_bigger',
|
||||||
|
),
|
||||||
|
|
||||||
url(r'^smaller/$', 'projector_edit', {'direction': 'smaller'},
|
url(r'^smaller/$',
|
||||||
name='projector_smaller'),
|
ProjectorEdit.as_view(),
|
||||||
|
{'direction': 'smaller'},
|
||||||
|
name='projector_smaller',
|
||||||
|
),
|
||||||
|
|
||||||
url(r'^up/$', 'projector_edit', {'direction': 'up'},
|
url(r'^up/$',
|
||||||
name='projector_up'),
|
ProjectorEdit.as_view(),
|
||||||
|
{'direction': 'up'},
|
||||||
|
name='projector_up',
|
||||||
|
),
|
||||||
|
|
||||||
url(r'^down/$', 'projector_edit', {'direction': 'down'},
|
url(r'^down/$',
|
||||||
name='projector_down'),
|
ProjectorEdit.as_view(),
|
||||||
|
{'direction': 'down'},
|
||||||
|
name='projector_down',
|
||||||
|
),
|
||||||
|
|
||||||
url(r'^clean/$', 'projector_edit', {'direction': 'clean'},
|
url(r'^clean/$',
|
||||||
name='projector_clean'),
|
ProjectorEdit.as_view(),
|
||||||
|
{'direction': 'clean'},
|
||||||
|
name='projector_clean',
|
||||||
|
),
|
||||||
|
|
||||||
# TODO: Merge the following lines with this one:
|
# TODO: Merge the following lines with this one:
|
||||||
## url(r'^countdown/(?P<command>[^/]*)/$',
|
## url(r'^countdown/(?P<command>[^/]*)/$',
|
||||||
|
|
|
@ -209,24 +209,25 @@ def active_slide(request, sid=None):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@permission_required('agenda.can_manage_agenda')
|
class ProjectorEdit(RedirectView):
|
||||||
def projector_edit(request, direction):
|
permission_required = 'projector.can_manage_projector'
|
||||||
if direction == 'bigger':
|
url = 'projector_control'
|
||||||
config['bigger'] = int(config['bigger']) + 20
|
allow_ajax = True
|
||||||
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
|
|
||||||
|
|
||||||
if request.is_ajax():
|
def pre_redirect(self, request, *args, **kwargs):
|
||||||
return ajax_request({})
|
direction = kwargs['direction']
|
||||||
return redirect(reverse('projector_control'))
|
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
|
||||||
|
|
||||||
|
|
||||||
class CountdownEdit(RedirectView):
|
class CountdownEdit(RedirectView):
|
||||||
|
@ -235,7 +236,7 @@ class CountdownEdit(RedirectView):
|
||||||
allow_ajax = True
|
allow_ajax = True
|
||||||
|
|
||||||
def pre_redirect(self, request, *args, **kwargs):
|
def pre_redirect(self, request, *args, **kwargs):
|
||||||
self.command = command = self.kwargs['command']
|
command = kwargs['command']
|
||||||
if command in ['reset', 'start', 'stop']:
|
if command in ['reset', 'start', 'stop']:
|
||||||
config['countdown_time'] = config['countdown_time']
|
config['countdown_time'] = config['countdown_time']
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue