Remove can_create and add get_toolbar_actions.

This commit is contained in:
long2ice
2021-05-19 15:30:18 +08:00
parent 3ee095fa0d
commit a3c01fc42c
6 changed files with 82 additions and 72 deletions

View File

@ -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 {}