Exemplo n.º 1
0
 def post(self, request, project_id, format=None):
     serializer = IntervalSerializer(data=request.data)
     project = Project.objects.get(pk=project_id, user=request.user.id)
     if serializer.is_valid():
         serializer.save(project=project)
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 2
0
 def post(self, request, project_id, format=None):
   serializer = IntervalSerializer(data=request.data)
   project = Project.objects.get(pk=project_id, user=request.user.id)
   if serializer.is_valid():
     serializer.save(project=project)
     return Response(serializer.data, status=status.HTTP_201_CREATED)
   return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 3
0
 def put(self, request, project_id, pk, format=None):
     interval = self.get_object(project_id, pk, request)
     serializer = IntervalSerializer(interval, data=request.data)
     if serializer.is_valid():
         serializer.save()
         project_object = self.get_project(project_id, request)
         project = ProjectSerializer(project_object)
         return Response(project.data)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 4
0
 def put(self, request, project_id, pk, format=None):
   interval = self.get_object(project_id, pk, request)
   serializer = IntervalSerializer(interval, data=request.data)
   if serializer.is_valid():
     serializer.save()
     project_object = self.get_project(project_id, request)
     project = ProjectSerializer(project_object)
     return Response(project.data)
   return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 5
0
def AllIntervals(request, format=None):
    intervals = Interval.objects.filter(project__user=request.user.id)
    serializer = IntervalSerializer(intervals, many=True)
    return Response(serializer.data)
Exemplo n.º 6
0
 def get(self, request, project_id, pk, format=None):
     interval = self.get_object(project_id, pk, request)
     serializer = IntervalSerializer(interval)
     return Response(serializer.data)
Exemplo n.º 7
0
 def get(self, request, project_id, format=None):
     project = Project.objects.get(pk=project_id, user=request.user.id)
     intervals = project.intervals.all().order_by('-created_at')
     serializer = IntervalSerializer(intervals, many=True)
     return Response(serializer.data)