Skip to content

Commit 62cca34

Browse files
committed
优化代码提示
1 parent 3911d4f commit 62cca34

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

fast_tmp/site/__init__.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from ..amis.enums import ButtonLevelEnum
1515
from ..amis.forms import Form
1616
from ..amis.frame import Dialog, Drawer
17-
from .util import AbstractControl, SelectByApi, create_column
17+
from .util import AbstractControl, BaseAdminControl, SelectByApi, create_column
1818

1919
logger = logging.getLogger(__file__)
2020

@@ -57,12 +57,11 @@ class ModelAdmin(DbSession): # todo inline字段必须都在update_fields内
5757
# exclude: Tuple[Union[str, BaseModel], ...] = ()
5858
# update ,如果为空则取create_fields
5959
update_fields: Tuple[str, ...] = ()
60-
fields: Dict[str, AbstractControl] = None # 存储字段名:control
61-
__list_display: Dict[str, AbstractControl] = {}
62-
__list_display_with_pk: Dict[str, AbstractControl] = {}
60+
fields: Dict[str, BaseAdminControl] = None # 存储字段名:control
61+
__list_display: Dict[str, BaseAdminControl] = {}
62+
__list_display_with_pk: Dict[str, BaseAdminControl] = {}
6363
methods: Tuple[str, ...] = (
6464
"list",
65-
"retrieve",
6665
"create",
6766
"put",
6867
"delete",
@@ -79,10 +78,10 @@ def name(self) -> str:
7978
self.__name = self.model.__name__
8079
return self.__name
8180

82-
def get_create_fields(self) -> Dict[str, AbstractControl]:
81+
def get_create_fields(self) -> Dict[str, BaseAdminControl]:
8382
return {i: self.fields[i] for i in self.create_fields}
8483

85-
def get_update_fields(self) -> Dict[str, AbstractControl]:
84+
def get_update_fields(self) -> Dict[str, BaseAdminControl]:
8685
return {i: self.fields[i] for i in self.update_fields}
8786

8887
async def get_create_dialogation_button(self, request: Request):
@@ -163,10 +162,10 @@ async def get_crud(self, request: Request):
163162
)
164163
return body
165164

166-
def get_list_distplay(self) -> Dict[str, AbstractControl]:
165+
def get_list_distplay(self) -> Dict[str, BaseAdminControl]:
167166
return {i: self.fields[i] for i in self.list_display}
168167

169-
def get_list_display_with_pk(self) -> Dict[str, AbstractControl]:
168+
def get_list_display_with_pk(self) -> Dict[str, BaseAdminControl]:
170169
ret = self.get_list_distplay()
171170
ret["pk"] = self.fields["pk"]
172171
return ret
@@ -208,7 +207,7 @@ async def create(self, request: Request, data: Dict[str, Any]) -> Model:
208207
return obj
209208

210209
def prefetch(
211-
self, request: Request, queryset: QuerySet, fields: Dict[str, AbstractControl]
210+
self, request: Request, queryset: QuerySet, fields: Dict[str, BaseAdminControl]
212211
) -> QuerySet:
213212
"""
214213
判断是否需要额外预加载的数据

0 commit comments

Comments
 (0)