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)
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)
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)
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)
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)
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)
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)
def get(self, request, pk): box = get_object_or_404(Box.objects.all(), pk=pk) return BoxResponse(box)