コード例 #1
0
 def post(self, request, pk):
     box = get_object_or_404(Box.objects.all(), pk=pk)
     request.data['box_id'] = pk
     serializer = InputPigTailPostSerializer(data=request.data)
     if serializer.is_valid(raise_exception=True):
         serializer.save()
     return BoxResponse(box)
コード例 #2
0
 def put(self, request, pk, output_pk):
     box = get_object_or_404(Box.objects.all(), pk=pk)
     pigtail = get_object_or_404(box.inbox_output.all(), output=output_pk)
     update_serializer = OutputPigTailPutSerializer(instance=pigtail,
                                                    data=request.data)
     if update_serializer.is_valid(raise_exception=True):
         update_serializer.save()
     return BoxResponse(box)
コード例 #3
0
 def put(self, request, pk, splitter_lbl):
     box = get_object_or_404(Box.objects.all(), pk=pk)
     splitter = get_object_or_404(box.inbox_splitter.all(),
                                  label=splitter_lbl)
     update_serializer = SplitterPutSerializer(instance=splitter,
                                               data=request.data)
     if update_serializer.is_valid(raise_exception=True):
         update_serializer.save()
     return BoxResponse(box)
コード例 #4
0
 def put(self, request, pk, fiber_pk):
     box = get_object_or_404(Box.objects.all(), pk=pk)
     fiber = get_object_or_404(box.inbox_fiber.all(), id=fiber_pk)
     if 'from_node' in request.data.keys():
         request.data['from_node']['box_id'] = pk
     if 'to_node' in request.data.keys():
         request.data['to_node']['box_id'] = pk
     update_serializer = FiberPutSerializer(instance=fiber,
                                            data=request.data)
     if update_serializer.is_valid(raise_exception=True):
         update_serializer.save()
     return BoxResponse(box)
コード例 #5
0
 def delete(self, request, pk, splitter_lbl):
     box = get_object_or_404(Box.objects.all(), pk=pk)
     splitter = get_object_or_404(box.inbox_splitter.all(),
                                  label=splitter_lbl)
     splitter.delete()
     return BoxResponse(box)
コード例 #6
0
 def delete(self, request, pk, fiber_pk):
     box = get_object_or_404(Box.objects.all(), pk=pk)
     fiber = get_object_or_404(box.inbox_fiber.all(), id=fiber_pk)
     fiber.delete()
     return BoxResponse(box)
コード例 #7
0
 def delete(self, request, pk, output_pk):
     box = get_object_or_404(Box.objects.all(), pk=pk)
     pigtail = get_object_or_404(box.inbox_output.all(), output=output_pk)
     pigtail.delete()
     return BoxResponse(box)
コード例 #8
0
 def get(self, request, pk):
     box = get_object_or_404(Box.objects.all(), pk=pk)
     return BoxResponse(box)