mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
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(
|
||||
data={'application_id': request.auth.keywords.get('application_id'),
|
||||
'user_id': request.user.id}).profile())
|
||||
else:
|
||||
raise AppAuthenticationFailed(401, "身份异常")
|
||||
raise AppAuthenticationFailed(401, "身份异常")
|
||||
|
||||
class ApplicationKey(APIView):
|
||||
authentication_classes = [TokenAuth]
|
||||
|
|
|
|||
|
|
@ -59,11 +59,11 @@ def exist_permissions(user_role: List[RoleConstants], user_permission: List[Perm
|
|||
**kwargs):
|
||||
if isinstance(permission, ViewPermission):
|
||||
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])
|
||||
elif isinstance(permission, PermissionConstants):
|
||||
if isinstance(permission, PermissionConstants):
|
||||
return exist_permissions_by_permission_constants(user_permission, [permission])
|
||||
elif isinstance(permission, Permission):
|
||||
if isinstance(permission, Permission):
|
||||
return user_permission.__contains__(permission)
|
||||
return False
|
||||
|
||||
|
|
@ -72,8 +72,7 @@ def exist(user_role: List[RoleConstants], user_permission: List[PermissionConsta
|
|||
if callable(permission):
|
||||
p = permission(request, kwargs)
|
||||
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):
|
||||
|
|
@ -92,8 +91,7 @@ def has_permissions(*permission, compare=CompareConstants.OR):
|
|||
# 判断是否有权限
|
||||
if any(exit_list) if compare == CompareConstants.OR else all(exit_list):
|
||||
return func(view, request, **kwargs)
|
||||
else:
|
||||
raise AppUnauthorizedFailed(403, "没有权限访问")
|
||||
raise AppUnauthorizedFailed(403, "没有权限访问")
|
||||
|
||||
return run
|
||||
|
||||
|
|
|
|||
|
|
@ -63,9 +63,9 @@ def find_err_detail(exc_detail):
|
|||
_value = exc_detail[key]
|
||||
if isinstance(_value, list):
|
||||
return find_err_detail(_value)
|
||||
elif isinstance(_value, ErrorDetail):
|
||||
if isinstance(_value, ErrorDetail):
|
||||
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)
|
||||
if isinstance(exc_detail, list):
|
||||
for v in exc_detail:
|
||||
|
|
|
|||
|
|
@ -57,16 +57,15 @@ def page_not_found(request, exception):
|
|||
"""
|
||||
if request.path.startswith("/api/"):
|
||||
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')
|
||||
if not os.path.exists(index_path):
|
||||
return HttpResponse("页面不存在", status=404)
|
||||
file = open(index_path, "r", encoding='utf-8')
|
||||
content = file.read()
|
||||
file.close()
|
||||
if request.path.startswith('/ui/chat/'):
|
||||
return HttpResponse(content, status=200)
|
||||
return HttpResponse(content, status=200, headers={'X-Frame-Options': 'DENY'})
|
||||
index_path = os.path.join(PROJECT_DIR, 'apps', "static", 'ui', 'index.html')
|
||||
if not os.path.exists(index_path):
|
||||
return HttpResponse("页面不存在", status=404)
|
||||
file = open(index_path, "r", encoding='utf-8')
|
||||
content = file.read()
|
||||
file.close()
|
||||
if request.path.startswith('/ui/chat/'):
|
||||
return HttpResponse(content, status=200)
|
||||
return HttpResponse(content, status=200, headers={'X-Frame-Options': 'DENY'})
|
||||
|
||||
|
||||
handler404 = page_not_found
|
||||
|
|
|
|||
Loading…
Reference in New Issue