fix(devices): update DeviceBlockAPIView to handle omada_client response correctly 🐛
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 5m24s

This commit is contained in:
2025-07-27 14:31:36 +05:00
parent d0c809489c
commit b52cd9285a

View File

@@ -145,10 +145,11 @@ class DeviceBlockAPIView(StaffEditorPermissionMixin, generics.UpdateAPIView):
if not isinstance(blocked, bool):
return Response({"message": "Blocked field must be a boolean."}, status=400)
omada_client = Omada()
blocked = omada_client.block_device(
omada_response = omada_client.block_device(
instance.mac, operation="block" if blocked else "unblock"
)
if blocked.errorCode == 0:
print(f"Blocked: {blocked}")
if omada_response.errorCode == 0:
instance.blocked = blocked
instance.save()
serializer = self.get_serializer(instance, data=request.data, partial=False)
@@ -157,7 +158,7 @@ class DeviceBlockAPIView(StaffEditorPermissionMixin, generics.UpdateAPIView):
return Response(serializer.data)
else:
return Response(
{"message": blocked.msg},
{"message": omada_response.msg},
status=status.HTTP_400_BAD_REQUEST,
)