rewrite projector_edit view as class based view

This commit is contained in:
Oskar Hahn 2012-07-01 10:52:08 +02:00
parent 2ba1b7e3bc
commit ea4da31b0c
2 changed files with 45 additions and 29 deletions

View File

@ -17,7 +17,7 @@ from openslides.utils.views import CreateView
from openslides.projector.models import ProjectorSlide
from openslides.projector.views import (ControlView, ActivateView,
CustomSlideCreateView, CustomSlideUpdateView, CustomSlideDeleteView,
CountdownEdit)
CountdownEdit, ProjectorEdit)
@ -63,20 +63,35 @@ urlpatterns = patterns('projector.views',
name='customslide_delete',
),
url(r'^bigger/$', 'projector_edit', {'direction': 'bigger'},
name='projector_bigger'),
url(r'^bigger/$',
ProjectorEdit.as_view(),
{'direction': 'bigger'},
name='projector_bigger',
),
url(r'^smaller/$', 'projector_edit', {'direction': 'smaller'},
name='projector_smaller'),
url(r'^smaller/$',
ProjectorEdit.as_view(),
{'direction': 'smaller'},
name='projector_smaller',
),
url(r'^up/$', 'projector_edit', {'direction': 'up'},
name='projector_up'),
url(r'^up/$',
ProjectorEdit.as_view(),
{'direction': 'up'},
name='projector_up',
),
url(r'^down/$', 'projector_edit', {'direction': 'down'},
name='projector_down'),
url(r'^down/$',
ProjectorEdit.as_view(),
{'direction': 'down'},
name='projector_down',
),
url(r'^clean/$', 'projector_edit', {'direction': 'clean'},
name='projector_clean'),
url(r'^clean/$',
ProjectorEdit.as_view(),
{'direction': 'clean'},
name='projector_clean',
),
# TODO: Merge the following lines with this one:
## url(r'^countdown/(?P<command>[^/]*)/$',

View File

@ -209,24 +209,25 @@ def active_slide(request, sid=None):
)
@permission_required('agenda.can_manage_agenda')
def projector_edit(request, 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
class ProjectorEdit(RedirectView):
permission_required = 'projector.can_manage_projector'
url = 'projector_control'
allow_ajax = True
if request.is_ajax():
return ajax_request({})
return redirect(reverse('projector_control'))
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
class CountdownEdit(RedirectView):
@ -235,7 +236,7 @@ class CountdownEdit(RedirectView):
allow_ajax = True
def pre_redirect(self, request, *args, **kwargs):
self.command = command = self.kwargs['command']
command = kwargs['command']
if command in ['reset', 'start', 'stop']:
config['countdown_time'] = config['countdown_time']