Fix pylint warning no-else-return (#678)
This commit is contained in:
parent
654aa377ce
commit
6c67b65e6a
@ -199,8 +199,7 @@ class Application(APIView):
|
|||||||
return result.success(ApplicationSerializer.Operate(
|
return result.success(ApplicationSerializer.Operate(
|
||||||
data={'application_id': request.auth.keywords.get('application_id'),
|
data={'application_id': request.auth.keywords.get('application_id'),
|
||||||
'user_id': request.user.id}).profile())
|
'user_id': request.user.id}).profile())
|
||||||
else:
|
raise AppAuthenticationFailed(401, "身份异常")
|
||||||
raise AppAuthenticationFailed(401, "身份异常")
|
|
||||||
|
|
||||||
class ApplicationKey(APIView):
|
class ApplicationKey(APIView):
|
||||||
authentication_classes = [TokenAuth]
|
authentication_classes = [TokenAuth]
|
||||||
|
|||||||
@ -59,11 +59,11 @@ def exist_permissions(user_role: List[RoleConstants], user_permission: List[Perm
|
|||||||
**kwargs):
|
**kwargs):
|
||||||
if isinstance(permission, ViewPermission):
|
if isinstance(permission, ViewPermission):
|
||||||
return exist_permissions_by_view_permission(user_role, user_permission, permission, request, **kwargs)
|
return exist_permissions_by_view_permission(user_role, user_permission, permission, request, **kwargs)
|
||||||
elif isinstance(permission, RoleConstants):
|
if isinstance(permission, RoleConstants):
|
||||||
return exist_role_by_role_constants(user_role, [permission])
|
return exist_role_by_role_constants(user_role, [permission])
|
||||||
elif isinstance(permission, PermissionConstants):
|
if isinstance(permission, PermissionConstants):
|
||||||
return exist_permissions_by_permission_constants(user_permission, [permission])
|
return exist_permissions_by_permission_constants(user_permission, [permission])
|
||||||
elif isinstance(permission, Permission):
|
if isinstance(permission, Permission):
|
||||||
return user_permission.__contains__(permission)
|
return user_permission.__contains__(permission)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -72,8 +72,7 @@ def exist(user_role: List[RoleConstants], user_permission: List[PermissionConsta
|
|||||||
if callable(permission):
|
if callable(permission):
|
||||||
p = permission(request, kwargs)
|
p = permission(request, kwargs)
|
||||||
return exist_permissions(user_role, user_permission, p, request)
|
return exist_permissions(user_role, user_permission, p, request)
|
||||||
else:
|
return exist_permissions(user_role, user_permission, permission, request, **kwargs)
|
||||||
return exist_permissions(user_role, user_permission, permission, request, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
def has_permissions(*permission, compare=CompareConstants.OR):
|
def has_permissions(*permission, compare=CompareConstants.OR):
|
||||||
@ -92,8 +91,7 @@ def has_permissions(*permission, compare=CompareConstants.OR):
|
|||||||
# 判断是否有权限
|
# 判断是否有权限
|
||||||
if any(exit_list) if compare == CompareConstants.OR else all(exit_list):
|
if any(exit_list) if compare == CompareConstants.OR else all(exit_list):
|
||||||
return func(view, request, **kwargs)
|
return func(view, request, **kwargs)
|
||||||
else:
|
raise AppUnauthorizedFailed(403, "没有权限访问")
|
||||||
raise AppUnauthorizedFailed(403, "没有权限访问")
|
|
||||||
|
|
||||||
return run
|
return run
|
||||||
|
|
||||||
|
|||||||
@ -63,9 +63,9 @@ def find_err_detail(exc_detail):
|
|||||||
_value = exc_detail[key]
|
_value = exc_detail[key]
|
||||||
if isinstance(_value, list):
|
if isinstance(_value, list):
|
||||||
return find_err_detail(_value)
|
return find_err_detail(_value)
|
||||||
elif isinstance(_value, ErrorDetail):
|
if isinstance(_value, ErrorDetail):
|
||||||
return _value
|
return _value
|
||||||
elif isinstance(_value, dict) and len(_value.keys()) > 0:
|
if isinstance(_value, dict) and len(_value.keys()) > 0:
|
||||||
return find_err_detail(_value)
|
return find_err_detail(_value)
|
||||||
if isinstance(exc_detail, list):
|
if isinstance(exc_detail, list):
|
||||||
for v in exc_detail:
|
for v in exc_detail:
|
||||||
|
|||||||
@ -57,16 +57,15 @@ def page_not_found(request, exception):
|
|||||||
"""
|
"""
|
||||||
if request.path.startswith("/api/"):
|
if request.path.startswith("/api/"):
|
||||||
return Result(response_status=status.HTTP_404_NOT_FOUND, code=404, message="找不到接口")
|
return Result(response_status=status.HTTP_404_NOT_FOUND, code=404, message="找不到接口")
|
||||||
else:
|
index_path = os.path.join(PROJECT_DIR, 'apps', "static", 'ui', 'index.html')
|
||||||
index_path = os.path.join(PROJECT_DIR, 'apps', "static", 'ui', 'index.html')
|
if not os.path.exists(index_path):
|
||||||
if not os.path.exists(index_path):
|
return HttpResponse("页面不存在", status=404)
|
||||||
return HttpResponse("页面不存在", status=404)
|
file = open(index_path, "r", encoding='utf-8')
|
||||||
file = open(index_path, "r", encoding='utf-8')
|
content = file.read()
|
||||||
content = file.read()
|
file.close()
|
||||||
file.close()
|
if request.path.startswith('/ui/chat/'):
|
||||||
if request.path.startswith('/ui/chat/'):
|
return HttpResponse(content, status=200)
|
||||||
return HttpResponse(content, status=200)
|
return HttpResponse(content, status=200, headers={'X-Frame-Options': 'DENY'})
|
||||||
return HttpResponse(content, status=200, headers={'X-Frame-Options': 'DENY'})
|
|
||||||
|
|
||||||
|
|
||||||
handler404 = page_not_found
|
handler404 = page_not_found
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user