some small fixes

This commit is contained in:
Oskar Hahn 2012-04-11 10:58:59 +02:00
parent 5e6180a465
commit 3eeae673c0
4 changed files with 18 additions and 4 deletions

View File

@ -3,6 +3,7 @@
\.pyc$ \.pyc$
\.swp$ \.swp$
^openslides/settings\.py$ ^openslides/settings\.py$
^openslides/urls\.py$
^database\.db$ ^database\.db$
~$ ~$
\.DS_Store$ \.DS_Store$
@ -11,5 +12,6 @@
^dist/ ^dist/
^versiontools ^versiontools
syntax:glob syntax:glob
*.egg-info *.egg-info

View File

@ -86,6 +86,8 @@ from openslides.utils.signals import template_manipulation
@receiver(template_manipulation, dispatch_uid="system_base_system") @receiver(template_manipulation, dispatch_uid="system_base_system")
def set_submenu(sender, request, context, **kwargs): def set_submenu(sender, request, context, **kwargs):
if sender.__class__.__module__ != 'system.views':
return None
selected = True if request.path == reverse('config_general') else False selected = True if request.path == reverse('config_general') else False
menu_links = [ menu_links = [
(reverse('config_general'), _('General'), selected), (reverse('config_general'), _('General'), selected),

View File

@ -26,7 +26,6 @@ from system.forms import SystemConfigForm, EventConfigForm
from system import config from system import config
class GeneralConfig(FormView): class GeneralConfig(FormView):
permission_required = 'system.can_manage_system' permission_required = 'system.can_manage_system'
form_class = EventConfigForm form_class = EventConfigForm
@ -97,4 +96,3 @@ def register_tab(request):
permission=request.user.has_perm('system.can_manage_system'), permission=request.user.has_perm('system.can_manage_system'),
selected=selected, selected=selected,
) )

View File

@ -28,6 +28,7 @@ from django.views.generic import (
CreateView as _CreateView, CreateView as _CreateView,
View as _View, View as _View,
FormView as _FormView, FormView as _FormView,
ListView as _ListView,
) )
from django.views.generic.detail import SingleObjectMixin from django.views.generic.detail import SingleObjectMixin
from django.utils.importlib import import_module from django.utils.importlib import import_module
@ -73,6 +74,13 @@ class TemplateView(PermissionMixin, _TemplateView):
return context return context
class ListView(PermissionMixin, _ListView):
def get_context_data(self, **kwargs):
context = super(ListView, self).get_context_data(**kwargs)
template_manipulation.send(sender=self, request=self.request, context=context)
return context
class RedirectView(PermissionMixin, _RedirectView): class RedirectView(PermissionMixin, _RedirectView):
permanent = False permanent = False
allow_ajax = False allow_ajax = False
@ -124,14 +132,14 @@ class UpdateView(PermissionMixin, _UpdateView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(UpdateView, self).get_context_data(**kwargs) context = super(UpdateView, self).get_context_data(**kwargs)
template_manipulation.send(sender=self, context=context) template_manipulation.send(sender=self, request=self.request, context=context)
return context return context
class CreateView(PermissionMixin, _CreateView): class CreateView(PermissionMixin, _CreateView):
def get_success_url(self): def get_success_url(self):
if 'apply' in self.request.POST: if 'apply' in self.request.POST:
return reverse('item_edit', args=[self.object.id]) return reverse(self.get_apply_url(), args=[self.object.id])
return reverse(super(CreateView, self).get_success_url()) return reverse(super(CreateView, self).get_success_url())
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
@ -139,6 +147,10 @@ class CreateView(PermissionMixin, _CreateView):
template_manipulation.send(sender=self, request=self.request, context=context) template_manipulation.send(sender=self, request=self.request, context=context)
return context return context
def get_apply_url(self):
#todo: Versuche apply url automatisch anhand on self.object herauszufindne
return self.apply_url
class DeleteView(RedirectView, SingleObjectMixin): class DeleteView(RedirectView, SingleObjectMixin):
def pre_redirect(self, request, *args, **kwargs): def pre_redirect(self, request, *args, **kwargs):