From 4bc131a82cfe9411df5548f07159137bd5d1540e Mon Sep 17 00:00:00 2001 From: wuaho Date: Sat, 9 Oct 2021 16:11:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A9=BA=E9=97=B4=E6=9D=83?= =?UTF-8?q?=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api_v1/endpoints/project.py | 3 ++- main.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/api_v1/endpoints/project.py b/api/api_v1/endpoints/project.py index 750e256..fb95c29 100644 --- a/api/api_v1/endpoints/project.py +++ b/api/api_v1/endpoints/project.py @@ -264,7 +264,8 @@ async def read_kanban( 'children': [], '_id': item['_id'] }) - res['spaces'][-1]['authority'] = 'rw' if current_user.id in item['members'] else 'r' + authority = {item['user_id']: item['authority'] for item in item['members']} + res['spaces'][-1]['authority'] = authority.get(current_user.id, 'r') for f in await crud.folder.find_many(db, {'pid': item['_id']}): res['spaces'][-1]['children'].append({ diff --git a/main.py b/main.py index 741224b..5b790ab 100644 --- a/main.py +++ b/main.py @@ -87,12 +87,12 @@ app.add_middleware( @app.exception_handler(RequestValidationError) async def validation_exception_handler(request, exc): - return Response(schemas.Msg(code='-4', msg='请求错误', data=str(exc)).json(), status_code=400) + return Response(schemas.Msg(code=-4, msg='请求错误', data=str(exc)).json(), status_code=400) @app.exception_handler(Exception) async def http_exception_handler(request, exc): - return Response(schemas.Msg(code='-3', msg='服务器错误').json(), status_code=500) + return Response(schemas.Msg(code=-3, msg='服务器错误').json(), status_code=500) @app.middleware("http")