def test_func(self): if not self.request.user.is_authenticated: return False elif not current_org.can_admin_by(self.request.user): self.raise_exception = True return False return True
def has_permission(self, request, view): if not current_org: return False if request.user.is_anonymous: return False return super(IsOrgAdminOrAppUser, self).has_permission(request, view) \ and (current_org.can_admin_by(request.user) or request.user.is_app)
def dispatch(self, request, *args, **kwargs): if not request.user.is_authenticated: return self.handle_no_permission() if not request.user.is_org_admin: return redirect('assets:user-asset-list') if not current_org or not current_org.can_admin_by(request.user): return redirect('orgs:switch-a-org') return super(IndexView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): print("Current org: {}".format(current_org)) if not request.user.is_authenticated: return super().dispatch(request, *args, **kwargs) if not current_org: return redirect('orgs:switch-a-org') if not current_org.can_admin_by(request.user): print("{} cannot admin {}".format(request.user, current_org)) if request.user.is_org_admin: print("Is org admin") return redirect('orgs:switch-a-org') return HttpResponseForbidden() else: print(current_org.can_admin_by(request.user)) return super().dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): if not request.user.is_authenticated: return super().dispatch(request, *args, **kwargs) if not current_org: return redirect('orgs:switch-a-org') if not current_org.can_admin_by(request.user): if request.user.is_org_admin: return redirect('orgs:switch-a-org') return HttpResponseForbidden() return super().dispatch(request, *args, **kwargs)
def can_admin_current_org(self): return current_org.can_admin_by(self)
def has_permission(self, request, view): if not current_org: return False return super(IsOrgAdmin, self).has_permission(request, view) \ and current_org.can_admin_by(request.user)
def has_permission(self, request, view): return super(IsOrgAdminOrAppUser, self).has_permission(request, view) \ and (current_org.can_admin_by(request.user) or request.user.is_app)
def has_permission(self, request, view): return super(IsOrgAdmin, self).has_permission(request, view) \ and current_org.can_admin_by(request.user)