From 0e95a7b1469e778324a3dcb78e0dbedd01056913 Mon Sep 17 00:00:00 2001 From: long2ice Date: Thu, 15 Oct 2020 12:54:44 +0800 Subject: [PATCH] Hide menu when no children menu. --- CHANGELOG.md | 4 ++++ fastapi_admin/__init__.py | 2 +- fastapi_admin/routes/site.py | 1 + pyproject.toml | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3512fd0..e13e6fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.3 +### 0.3.2 + +- Hide menu when no children menu. + ### 0.3.1 - Auto register permission. diff --git a/fastapi_admin/__init__.py b/fastapi_admin/__init__.py index dcf4f71..0202887 100644 --- a/fastapi_admin/__init__.py +++ b/fastapi_admin/__init__.py @@ -5,4 +5,4 @@ def version(): # with open("pyproject.toml") as f: # ret = re.findall(r'version = "(\d+\.\d+\.\d+)"', f.read()) # return ret[0] - return "0.3.1" + return "0.3.2" diff --git a/fastapi_admin/routes/site.py b/fastapi_admin/routes/site.py index 976b444..a443f08 100644 --- a/fastapi_admin/routes/site.py +++ b/fastapi_admin/routes/site.py @@ -30,4 +30,5 @@ async def site(user_id=Depends(jwt_optional)): model = child.url.split("/")[-1] if not await check_has_permission(user, model): site_copy.menus[index].children.remove(child) + site_copy.menus = list(filter(lambda x: x.children != [], site_copy.menus)) return site_copy.dict(by_alias=True, exclude_unset=True) diff --git a/pyproject.toml b/pyproject.toml index 5a01c98..e3bf45d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fastapi-admin" -version = "0.3.1" +version = "0.3.2" description = "Fast Admin Dashboard based on fastapi and tortoise-orm." authors = ["long2ice "] license = "Apache-2.0"