diff --git a/docs/en/docs/custom/admin_log.md b/docs/en/docs/custom/admin_log.md new file mode 100644 index 0000000..f025050 --- /dev/null +++ b/docs/en/docs/custom/admin_log.md @@ -0,0 +1 @@ +# Admin Log Provider diff --git a/docs/en/docs/custom/permission.md b/docs/en/docs/custom/permission.md new file mode 100644 index 0000000..a2c1e9f --- /dev/null +++ b/docs/en/docs/custom/permission.md @@ -0,0 +1 @@ +# Permission Provider diff --git a/docs/en/docs/custom/search.md b/docs/en/docs/custom/search.md new file mode 100644 index 0000000..613564c --- /dev/null +++ b/docs/en/docs/custom/search.md @@ -0,0 +1 @@ +# Search Provider diff --git a/docs/en/docs/getting_started/installation.md b/docs/en/docs/getting_started/installation.md index c03cd06..0080e06 100644 --- a/docs/en/docs/getting_started/installation.md +++ b/docs/en/docs/getting_started/installation.md @@ -10,7 +10,7 @@ You can install from pypi. ## From source -Or you can install from source with latest code. +Or you can install from source with the latest code. ```shell > pip install git+https://github.com/fastapi-admin/fastapi-admin.git @@ -21,7 +21,7 @@ Or you can install from source with latest code. Add the following line. ``` --e https://github.com/fastapi-admin/fastapi-admin.git@develop#egg=fastapi-admin +-e https://github.com/fastapi-admin/fastapi-admin.git#egg=fastapi-admin ``` ### With poetry @@ -29,5 +29,5 @@ Add the following line. Add the following line in section `[tool.poetry.dependencies]`. ```toml -fastapi-admin = { git = 'https://github.com/fastapi-admin/fastapi-admin.git', branch = 'develop' } +fastapi-admin = { git = 'https://github.com/fastapi-admin/fastapi-admin.git' } ``` diff --git a/docs/en/docs/getting_started/quick_start.md b/docs/en/docs/getting_started/quick_start.md index c061da2..65665f4 100644 --- a/docs/en/docs/getting_started/quick_start.md +++ b/docs/en/docs/getting_started/quick_start.md @@ -62,7 +62,7 @@ from fastapi_admin.resources import Link @app.register class Home(Link): label = "Home" - icon = "ti ti-home" + icon = "fas fa-home" url = "/admin" ``` @@ -76,19 +76,22 @@ The `Model` make a TortoiseORM model as a menu with CURD page. ```python -from examples.models import User +from examples.models import Admin from fastapi_admin.app import app -from fastapi_admin.resources import Field, Model +from fastapi_admin.resources import Field, Model,Action from fastapi_admin.widgets import displays, filters, inputs +from typing import List +from fastapi_admin.providers.file_upload import FileUploadProvider +upload_provider = FileUploadProvider(uploads_dir=os.path.join(BASE_DIR, "static", "uploads")) @app.register -class UserResource(Model): - label = "User" - model = User - icon = "ti ti-user" - page_pre_title = "user list" - page_title = "user model" +class AdminResource(Model): + label = "Admin" + model = Admin + icon = "fas fa-user" + page_pre_title = "admin list" + page_title = "admin model" filters = [ filters.Search( name="username", label="Name", search_mode="contains", placeholder="Search for username" @@ -111,10 +114,15 @@ class UserResource(Model): display=displays.Image(width="40"), input_=inputs.Image(null=True, upload_provider=upload_provider), ), - "is_superuser", - "is_active", "created_at", ] + can_create = False + + def get_actions(self) -> List[Action]: + return [] + + def get_bulk_actions(self) -> List[Action]: + return [] ``` ### Dropdown @@ -158,7 +166,7 @@ class Content(Dropdown): ] label = "Content" - icon = "ti ti-package" + icon = "fas fa-bars" resources = [ProductResource, CategoryResource] ``` diff --git a/docs/en/docs/pro/exclusive.md b/docs/en/docs/pro/exclusive.md index 5d62e4b..6de673d 100644 --- a/docs/en/docs/pro/exclusive.md +++ b/docs/en/docs/pro/exclusive.md @@ -68,3 +68,17 @@ admin_app.configure(maintenance=True) ``` ## Admin Log + +If you want to log all `create/update/delete` actions, you can set `admin_log_provider` to `admin_app.configure(...)`. + +```python +admin_app.configure(admin_log_provider=AdminLogProvider(Log)) +``` + +## Site Search + +You can enable site search by set `search_provider` to `admin_app.configure(...)`. + +```python +admin_app.configure(search_provider=SearchProvider()) +``` diff --git a/docs/en/docs/pro/installation.md b/docs/en/docs/pro/installation.md index 5562416..c19a5db 100644 --- a/docs/en/docs/pro/installation.md +++ b/docs/en/docs/pro/installation.md @@ -22,7 +22,7 @@ In order to access the repository programmatically (from the command line or Git Add the following line in section `[tool.poetry.dependencies]`. ```toml -fastapi-admin-pro = { git = 'https://${GH_TOKEN}@github.com/fastapi-admin/fastapi-admin-pro.git', branch = 'develop' } +fastapi-admin-pro = { git = 'https://${GH_TOKEN}@github.com/fastapi-admin/fastapi-admin-pro.git'} ``` ## In requirements.txt @@ -30,5 +30,5 @@ fastapi-admin-pro = { git = 'https://${GH_TOKEN}@github.com/fastapi-admin/fastap Add the following line. ```shell --e https://${GH_TOKEN}@github.com/fastapi-admin/fastapi-admin-pro.git@develop#egg=fastapi-admin-pro +-e https://${GH_TOKEN}@github.com/fastapi-admin/fastapi-admin-pro.git#egg=fastapi-admin-pro ``` diff --git a/docs/en/docs/reference/errors.md b/docs/en/docs/reference/errors.md new file mode 100644 index 0000000..9addf89 --- /dev/null +++ b/docs/en/docs/reference/errors.md @@ -0,0 +1 @@ +# Error Pages (💗 Pro only) diff --git a/docs/en/docs/reference/index.md b/docs/en/docs/reference/index.md index 21392ca..bbdcf18 100644 --- a/docs/en/docs/reference/index.md +++ b/docs/en/docs/reference/index.md @@ -28,7 +28,7 @@ Current support `zh` and `en`, default is `en`. ## template_folders -Template folders used to override builtin templates. +Template folders registered to jinja2 and also can be used to override builtin templates. ## login_provider @@ -45,7 +45,8 @@ Show captcha in admin login page. ## permission_provider (💗 Pro only) -You can enable permission control by setting `permission_provider`. +You can enable permission control by setting `permission_provider`, which is instance +of `fastapi_admin.providers.permission.PermissionProvider` of its subclass. ### admin_model @@ -59,14 +60,11 @@ Subclass of `fastapi_admin.models.AbstractResource`. Subclass of `fastapi_admin.models.AbstractPermission`. -### role_model +## admin_log_provider -Subclass of `fastapi_admin.models.AbstractRole`. - -## log_model - -You can enable action log by set `log_model`, which is subclass of `fastapi_admin.models.AbstractLog`. After set that, -all `delete/create/update` for model will be recorded. +You can enable action log by set `admin_log_provider`, which is instance +of `fastapi_admin.providers.admin_log.AdminLogProvider` or its subclass. After set that, all `delete/create/update` for +model will be recorded. ## search_provider (💗 Pro only) diff --git a/docs/en/docs/reference/resource.md b/docs/en/docs/reference/resource.md index 049bfb6..13029c0 100644 --- a/docs/en/docs/reference/resource.md +++ b/docs/en/docs/reference/resource.md @@ -12,7 +12,7 @@ Nav bar menu name. ### icon -Icon name comes from , like `ti ti-user` will display a user icon in menu. +Icon name comes from , like `fas fa-user` will display a user icon in menu. ## Link diff --git a/docs/en/mkdocs.yml b/docs/en/mkdocs.yml index 7ca703a..03b1e82 100644 --- a/docs/en/mkdocs.yml +++ b/docs/en/mkdocs.yml @@ -53,12 +53,16 @@ nav: - reference/global_search.md - reference/actions.md - reference/bulk_actions.md + - reference/errors.md - Customization: - custom/page.md - custom/overwrite.md + - custom/widget.md - custom/login.md - custom/file.md - - custom/widget.md + - custom/search.md + - custom/admin_log.md + - custom/permission.md - Pro Version For Sponsor: - pro/sponsor.md - pro/exclusive.md diff --git a/examples/resources.py b/examples/resources.py index 96be721..6aa298b 100644 --- a/examples/resources.py +++ b/examples/resources.py @@ -126,3 +126,11 @@ class DocumentationLink(Link): url = "https://long2ice.github.io/fastadmin" icon = "fas fa-file-code" target = "_blank" + + +@app.register +class ProLink(Link): + label = "Pro Version" + url = "https://fastapi-admin-pro.long2ice.cn" + icon = "far fa-heart" + target = "_blank"