示例#1
0
 def post(self, request, id):
     data = json.loads(request.body)
     data['task_list'] = id
     ser = TaskSerializer(data=data)
     if ser.is_valid():
         ser.save()
         return JsonResponse(ser.data, status=201)
     return JsonResponse(ser.errors, status=400)
示例#2
0
 def retrieve(self, request, pk=None, **kwargs):
     assignee = request.user.profile
     queryset = Task.objects.filter(assignee=assignee,
                                    organization=assignee.organiz_login)
     task = get_object_or_404(queryset, pk=pk)
     serializer = TaskSerializer(task)
     return Response(serializer.data)
示例#3
0
    def get(self, request, id):
        try:
            tasks = models.Task.objects.get(task_list=id)
        except models.Task.DoesNotExist as e:
            return JsonResponse({'error': 'tasklist with such id does not exist'}, safe=False)

            ser = TaskSerializer(tasks, many=True)

        return JsonResponse(ser.data, status=201, safe=False)
示例#4
0
 def get(self, request, pk, format=None):
     task = self.get_object(pk)
     serializer = TaskSerializer(task)
     return Response(serializer.data)
示例#5
0
 def tasks(self, request, pk):
     instance = self.get_object()
     serializer = TaskSerializer(instance.tasks, many=True)
     return Response(serializer.data)
示例#6
0
 def post(self, request):
     serializer = TaskSerializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     serializer.create(request)
     return Response(serializer.data)
示例#7
0
 def get(self, request):
     tasks = Task.objects.filter(creator_id=request.user.id,
                                 block_id=request.query_params['block_id'])
     serializer = TaskSerializer(tasks, many=True)
     return Response(serializer.data)
示例#8
0
 def list(self, request, **kwargs):
     assignee = request.user.profile
     queryset = Task.objects.filter(assignee=assignee,
                                    organization=assignee.organiz_login)
     serializer = TaskSerializer(queryset, many=True)
     return Response(serializer.data)
示例#9
0
 def tasks(self, request, pk):
     tasks = Task.objects.filter(block_id=pk)
     serializer = TaskSerializer(tasks, many=True)
     return Response(serializer.data)
示例#10
0
 def tasks(self, request, pk):
     block = self.get_object()
     serializer = TaskSerializer(block.tasks, many=True)
     return Response(serializer.data)