mirror of
https://github.com/fastapi-admin/fastapi-admin.git
synced 2025-08-14 18:58:13 +08:00
Remove can_create
and add get_toolbar_actions
.
This commit is contained in:
@ -68,6 +68,10 @@ class Action(BaseModel):
|
||||
raise ValueError("ajax is False only available when method is Method.GET")
|
||||
|
||||
|
||||
class ToolbarAction(Action):
|
||||
class_: Optional[str]
|
||||
|
||||
|
||||
class Model(Resource):
|
||||
model: Type[TortoiseModel]
|
||||
fields: List[Union[str, Field]] = []
|
||||
@ -78,6 +82,18 @@ class Model(Resource):
|
||||
can_create: bool = True
|
||||
enctype = "application/x-www-form-urlencoded"
|
||||
|
||||
async def get_toolbar_actions(self, request: Request) -> List[ToolbarAction]:
|
||||
return [
|
||||
ToolbarAction(
|
||||
label=_("create"),
|
||||
icon="fas fa-plus",
|
||||
name="create",
|
||||
method=Method.GET,
|
||||
ajax=False,
|
||||
class_="btn-dark",
|
||||
)
|
||||
]
|
||||
|
||||
async def row_attributes(self, request: Request, obj: dict) -> dict:
|
||||
return {}
|
||||
|
||||
|
Reference in New Issue
Block a user