mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-10-05 01:15:23 +00:00
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
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 5m24s
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user