示例#1
0
 def create(self, request, *args, **kwargs):
     project_pk = request.data.get('project')
     if project_pk not in [
             project.id
             for project in get_user_permitted_projects(self.request.user)
     ]:
         return Response(status=status.HTTP_403_FORBIDDEN)
     return super().create(request, *args, **kwargs)
示例#2
0
    def create(self, request, *args, **kwargs):
        project_pk = request.data.get('project')

        if not project_pk:
            return Response(data={"detail": "No project provided"},
                            status=status.HTTP_400_BAD_REQUEST)

        get_object_or_404(get_user_permitted_projects(self.request.user),
                          pk=project_pk)

        return super().create(request, *args, **kwargs)
示例#3
0
    def get_queryset(self):
        project = get_object_or_404(get_user_permitted_projects(
            self.request.user),
                                    pk=self.kwargs['project_pk'])
        queryset = project.segments.all()

        identity_pk = self.request.query_params.get('identity')
        if identity_pk:
            identity = Identity.objects.get(pk=identity_pk)
            queryset = queryset.filter(
                id__in=[segment.id for segment in identity.get_segments()])

        return queryset
示例#4
0
 def get_queryset(self):
     project = get_object_or_404(get_user_permitted_projects(
         self.request.user),
                                 pk=self.kwargs['project_pk'])
     return project.segments.all()
示例#5
0
    def get_queryset(self):
        user_projects = get_user_permitted_projects(self.request.user)
        project = get_object_or_404(user_projects,
                                    pk=self.kwargs['project_pk'])

        return project.features.all()