Пример #1
0
 def get(self, request, format=None):
     """
     List all workflow
     ---
     response_serializer: serializers.WorkflowSerializer
     """
     workflows = Workflow.objects.all()
     serializer = serializers.WorkflowSerializer(workflows, many=True)
     return Response(serializer.data, status=status.HTTP_200_OK)
Пример #2
0
 def get(self, request, workflow_pk, format=None):
     """
     Retrieve details of selected workflow
     ---
     response_serializer: serializers.WorkflowSerializer
     """
     workflow = get_object_or_404(Workflow, pk=workflow_pk)
     serializer = serializers.WorkflowSerializer(workflow)
     return Response(serializer.data, status=status.HTTP_200_OK)
Пример #3
0
 def get(self, request, project_pk, format=None):
     """
     List all workflow of selected project
     ---
     response_serializer: serializers.WorkflowSerializer
     """
     project = get_object_or_404(Project, pk=project_pk)
     workflows = Workflow.objects.filter(project=project)
     serializer = serializers.WorkflowSerializer(workflows, many=True)
     return Response(serializer.data, status=status.HTTP_200_OK)
Пример #4
0
 def post(self, request, format=None):
     """
     Create new workflow
     ---
     request_serializer: serializers.WorkflowSerializer
     response_serializer: serializers.WorkflowSerializer
     """
     serializer = serializers.WorkflowSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     else:
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Пример #5
0
 def patch(self, request, workflow_pk, format=None):
     """
     Update informations of selected workflow
     ---
     request_serializer: serializers.WorkflowSerializer
     response_serializer: serializers.WorkflowSerializer
     """
     workflow = get_object_or_404(Workflow, pk=workflow_pk)
     serializer = serializers.WorkflowSerializer(workflow, data=request.data, partial=True)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_200_OK)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Пример #6
0
 def get(self, request, person_pk, format=None):
     """
     Display workflow with selected filter
     ---
     response_serializer: serializers.WorkflowSerializer
     """
     person = get_object_or_404(Person, pk=person_pk)
     workflows = Workflow.objects.filter(archived=False)
     workflows_list = set()
     for workflow in workflows:
         if workflow.get_items('mine', person=person):
             workflows_list.add(workflow)
     serializer = serializers.WorkflowSerializer(workflows_list, many=True)
     return Response(serializer.data, status=status.HTTP_200_OK)