fix role memory
All checks were successful
Build and Deploy Backend / build-and-deploy (push) Successful in 23m5s

This commit is contained in:
repair-agent 2026-03-26 10:53:39 +08:00
parent cccb1b6213
commit ea2b60d91c

View File

@ -149,7 +149,13 @@ class DeviceViewSet(viewsets.ViewSet):
user=request.user, device=device
).select_related('role_memory').first()
if existing_binding and existing_binding.role_memory:
# 普通电子吧唧(DZBJ-OFF)不需要角色记忆
product_code = device.device_type.product_code if device.device_type else ''
needs_role_memory = product_code != 'DZBJ-OFF'
if not needs_role_memory:
role_memory = None
elif existing_binding and existing_binding.role_memory:
# 已有绑定且有角色记忆 → 复用,不重复创建
role_memory = existing_binding.role_memory
role_memory.is_bound = True