예제 #1
0
    def list(self, request, parent_lookup_processstep):
        step = ProcessStep.objects.get(pk=parent_lookup_processstep)
        child_steps = step.child_steps.all()
        child_steps = ProcessStepFilter(data=request.query_params,
                                        queryset=child_steps,
                                        request=self.request).qs

        tasks = step.tasks.all().select_related('responsible')
        tasks = ProcessTaskFilter(data=request.query_params,
                                  queryset=tasks,
                                  request=self.request).qs

        queryset = sorted(itertools.chain(child_steps, tasks),
                          key=lambda instance: instance.get_pos())

        page = self.paginate_queryset(queryset)

        if page is not None:
            serializers = ProcessStepChildrenSerializer(
                page, many=True, context={'request': request})
            return self.get_paginated_response(serializers.data)

        serializers = ProcessStepChildrenSerializer(
            queryset, many=True, context={'request': request})
        return Response(serializers.data)
예제 #2
0
파일: views.py 프로젝트: Axenu/ESSArch_Core
    def list(self, request, parent_lookup_processstep):
        hidden = request.query_params.get('hidden')

        if hidden in ['True', 'true', True]:
            hidden = True

        elif hidden in ['False', 'false', False]:
            hidden = False

        step = ProcessStep.objects.get(pk=parent_lookup_processstep)
        child_steps = step.child_steps.all()
        tasks = step.tasks.all().select_related('responsible')

        if hidden is True:
            child_steps = child_steps.filter(hidden=True)
            tasks = tasks.filter(hidden=True)
        elif hidden is False:
            child_steps = child_steps.filter(hidden=False)
            tasks = tasks.filter(hidden=False)

        queryset = sorted(
            itertools.chain(child_steps, tasks),
            key=lambda instance: instance.time_started or datetime.datetime(
                datetime.MAXYEAR, 1, 1, 1, 1, 1, 1, pytz.UTC))

        page = self.paginate_queryset(queryset)

        if page is not None:
            serializers = ProcessStepChildrenSerializer(
                page, many=True, context={'request': request})
            return self.get_paginated_response(serializers.data)

        serializers = ProcessStepChildrenSerializer(
            queryset, many=True, context={'request': request})
        return Response(serializers.data)
예제 #3
0
    def workflow(self, request, pk=None):
        ip = self.get_object()
        hidden = request.query_params.get('hidden')

        steps = ip.steps.filter(parent_step__information_package__isnull=True)
        tasks = ip.processtask_set.filter(
            processstep__information_package__isnull=True)

        if hidden is not None:
            steps = steps.filter(hidden=string_to_bool(hidden))
            tasks = tasks.filter(hidden=string_to_bool(hidden))

        flow = sorted(itertools.chain(steps, tasks),
                      key=lambda x: (x.get_pos(), x.time_created))

        serializer = ProcessStepChildrenSerializer(
            data=flow, many=True, context={'request': request})
        serializer.is_valid()
        return Response(serializer.data)