fixed deletion of motions. #391

This commit is contained in:
Oskar Hahn 2012-10-24 12:45:40 +02:00
parent 57d591fee8
commit 413cd27d40
2 changed files with 6 additions and 3 deletions

View File

@ -426,10 +426,13 @@ class MotionDelete(DeleteView):
"""
Delete one or more Motions.
"""
permission_required = 'motion.can_manage_motion'
model = Motion
url = 'motion_overview'
def has_permission(self, request, *args, **kwargs):
self.kwargs = kwargs
return self.get_object().get_allowed_actions(request.user)
def get_object(self):
self.motions = []

View File

@ -80,14 +80,14 @@ class LoginMixin(object):
class PermissionMixin(object):
permission_required = NO_PERMISSION_REQUIRED
def has_permission(self, request):
def has_permission(self, request, *args, **kwargs):
if self.permission_required == NO_PERMISSION_REQUIRED:
return True
else:
return request.user.has_perm(self.permission_required)
def dispatch(self, request, *args, **kwargs):
if not self.has_permission(request):
if not self.has_permission(request, *args, **kwargs):
if not request.user.is_authenticated():
path = request.get_full_path()
return HttpResponseRedirect("%s?next=%s" % (settings.LOGIN_URL,