コード例 #1
0
ファイル: sliceplus.py プロジェクト: Chunhai/xos-1
    def get_queryset(self):
        current_user_can_see = self.request.query_params.get('current_user_can_see', False)
        site_filter = self.request.query_params.get('site', False)

        if (not self.request.user.is_authenticated()):
            raise XOSPermissionDenied("You must be authenticated in order to use this API")

        slices = SlicePlus.select_by_user(self.request.user)

        if (site_filter and not current_user_can_see):
            slices = SlicePlus.objects.filter(site=site_filter)

        # If current_user_can_see is set, then filter the queryset to return
        # only those slices that the user is either creator or has privilege
        # on.
        if (current_user_can_see):
            slice_ids = []
            for slice in slices:
                if (self.request.user == slice.creator) or (len(slice.getSliceInfo(self.request.user)["roles"]) > 0):
                    slice_ids.append(slice.id)
            if (site_filter):
                slices = SlicePlus.objects.filter(id__in=slice_ids, site=site_filter)
            else:
                slices = SlicePlus.objects.filter(id__in=slice_ids)

        return slices
コード例 #2
0
ファイル: sliceplus.py プロジェクト: th3architect/xos
    def get_queryset(self):
        current_user_can_see = self.request.query_params.get(
            'current_user_can_see', False)
        site_filter = self.request.query_params.get('site', False)

        if (not self.request.user.is_authenticated()):
            raise XOSPermissionDenied(
                "You must be authenticated in order to use this API")

        slices = SlicePlus.select_by_user(self.request.user)

        if (site_filter and not current_user_can_see):
            slices = SlicePlus.objects.filter(site=site_filter)

        # If current_user_can_see is set, then filter the queryset to return
        # only those slices that the user is either creator or has privilege
        # on.
        if (current_user_can_see):
            slice_ids = []
            for slice in slices:
                if (self.request.user == slice.creator) or (len(
                        slice.getSliceInfo(self.request.user)["roles"]) > 0):
                    slice_ids.append(slice.id)
            if (site_filter):
                slices = SlicePlus.objects.filter(id__in=slice_ids,
                                                  site=site_filter)
            else:
                slices = SlicePlus.objects.filter(id__in=slice_ids)

        return slices
コード例 #3
0
ファイル: sliceplus.py プロジェクト: Chunhai/xos-1
 def get_queryset(self):
     if (not self.request.user.is_authenticated()):
         raise XOSPermissionDenied("You must be authenticated in order to use this API")
     return SlicePlus.select_by_user(self.request.user)
コード例 #4
0
 def get_queryset(self):
     if (not self.request.user.is_authenticated()):
         raise XOSPermissionDenied("You must be authenticated in order to use this API")
     return SlicePlus.select_by_user(self.request.user)