|
@@ -407,48 +407,38 @@ class setUserValidView(View):
|
|
|
return response.json(800)
|
|
|
|
|
|
def UserValidUpdatePC(self, superID, eUserID, isValid, rid, response):
|
|
|
- try:
|
|
|
- super = Device_User.objects.filter(userID=superID)
|
|
|
- eUser = Device_User.objects.filter(userID=eUserID)
|
|
|
- except Exception as e:
|
|
|
- errorInfo = traceback.format_exc()
|
|
|
- print('查询数据库错误: %s' % errorInfo)
|
|
|
- return response.json(500, repr(e))
|
|
|
- else:
|
|
|
- if not super:
|
|
|
- return response.json(615)
|
|
|
- if not eUser:
|
|
|
- return response.json(616)
|
|
|
- own_permission = ModelService.check_permission(userID=superID, permID=50)
|
|
|
- if own_permission is True:
|
|
|
- try:
|
|
|
- eUser.update(user_isValid=isValid)
|
|
|
- device_user_query_set = Device_User.objects.get(userID=eUserID)
|
|
|
- if device_user_query_set.role.all():
|
|
|
- device_user_query_set.role.set([rid])
|
|
|
- else:
|
|
|
- role_user_query_set = Role.objects.get(rid=rid)
|
|
|
- device_user_query_set.role.add(role_user_query_set)
|
|
|
- except Exception as e:
|
|
|
- errorInfo = traceback.format_exc()
|
|
|
- print('更新数据库错误:%s' % errorInfo)
|
|
|
- return response.json(501, repr(e))
|
|
|
+ super = Device_User.objects.filter(userID=superID)
|
|
|
+ eUser = Device_User.objects.filter(userID=eUserID)
|
|
|
+ if not super.exists():
|
|
|
+ return response.json(615)
|
|
|
+ if not eUser.exists():
|
|
|
+ return response.json(616)
|
|
|
+ own_permission = ModelService.check_permission(userID=superID, permID=50)
|
|
|
+ if own_permission is True:
|
|
|
+ try:
|
|
|
+ eUser.update(user_isValid=isValid)
|
|
|
+ device_user_query_set = Device_User.objects.get(userID=eUserID)
|
|
|
+ if device_user_query_set.role.all():
|
|
|
+ device_user_query_set.role.set([rid])
|
|
|
else:
|
|
|
- return response.json(0)
|
|
|
+ role_user_query_set = Role.objects.get(rid=rid)
|
|
|
+ device_user_query_set.role.add(role_user_query_set)
|
|
|
+ except Exception as e:
|
|
|
+ errorInfo = traceback.format_exc()
|
|
|
+ print('更新数据库错误:%s' % errorInfo)
|
|
|
+ return response.json(501, repr(e))
|
|
|
else:
|
|
|
- return response.json(602)
|
|
|
+ return response.json(0)
|
|
|
+ else:
|
|
|
+ return response.json(602)
|
|
|
+
|
|
|
|
|
|
def UserValidUpdate(self, superID, eUserID, isValid, response):
|
|
|
- try:
|
|
|
- super = Device_User.objects.filter(userID=superID)
|
|
|
- eUser = Device_User.objects.filter(userID=eUserID)
|
|
|
- except Exception as e:
|
|
|
- errorInfo = traceback.format_exc()
|
|
|
- print('查询数据库错误: %s' % errorInfo)
|
|
|
- return response.json(500, repr(e))
|
|
|
- if not super:
|
|
|
+ super = Device_User.objects.filter(userID=superID)
|
|
|
+ eUser = Device_User.objects.filter(userID=eUserID)
|
|
|
+ if not super.exists():
|
|
|
return response.json(113)
|
|
|
- if not eUser:
|
|
|
+ if not eUser.exists():
|
|
|
return response.json(113)
|
|
|
if super[0].is_superuser != 100 or super[0].is_superuser == eUser[0].is_superuser:
|
|
|
return response.json(602)
|