From b52cd9285a9a44dd2e18c9d97fd1718252cf34c9 Mon Sep 17 00:00:00 2001 From: i701 Date: Sun, 27 Jul 2025 14:31:36 +0500 Subject: [PATCH] =?UTF-8?q?fix(devices):=20update=20DeviceBlockAPIView=20t?= =?UTF-8?q?o=20handle=20omada=5Fclient=20response=20correctly=20?= =?UTF-8?q?=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devices/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/devices/views.py b/devices/views.py index f27c03a..7f13afc 100644 --- a/devices/views.py +++ b/devices/views.py @@ -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, )