Exemple #1
0
 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
Exemple #2
0
 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 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
Exemple #4
0
 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)
Exemple #5
0
 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)
Exemple #6
0
    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)
Exemple #7
0
    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 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)
Exemple #9
0
 def can_admin_current_org(self):
     return current_org.can_admin_by(self)
Exemple #10
0
 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)
Exemple #11
0
 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(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)