class HasPermissionDetailView(DetailView): @method_decorator(has_permission_decorator('permission2')) def dispatch(self, request, *args, **kwargs): return super(HasPermissionDetailView, self).dispatch(request, *args, **kwargs) def get_object(self): return True def render_to_response(self, context, **response_kwargs): return HttpResponse("Test")
class PermissionOverhiddenRedirectView(DetailView): @method_decorator( has_permission_decorator('permission2', redirect_to_login=False)) def dispatch(self, request, *args, **kwargs): return super(PermissionOverhiddenRedirectView, self).dispatch(request, *args, **kwargs) def get_object(self): return True def render_to_response(self, context, **response_kwargs): return HttpResponse("Test")
def dispatch(self, request, *args, **kwargs): permission = self.required_permission return (has_permission_decorator(permission)(super( HasPermissionsMixin, self).dispatch)(request, *args, **kwargs))
def dispatch(self, request, *args, **kwargs): permission = self.required_permission return (has_permission_decorator(permission, redirect_to_login=self.redirect_to_login) (super(HasPermissionsMixin, self).dispatch) (request, *args, **kwargs))