@@ -412,31 +412,6 @@ def save_model_params_form(self, model_params_form, with_valid=True):
412412 return True
413413
414414
415- def get_authorized_tool (tool_query_set , workspace_id , model_workspace_authorization ):
416- # 对所有工作空间拉黑的工具
417- non_auths = QuerySet (model_workspace_authorization ).filter (
418- Q (workspace_id = 'None' ) & Q (authentication_type = 'WHITE_LIST' )
419- ).values_list ('model_id' , flat = True )
420- # 授权给所有工作空间的工具
421- all_auths = QuerySet (model_workspace_authorization ).filter (
422- Q (workspace_id = 'None' ) & Q (authentication_type = 'BLACK_LIST' )
423- ).values_list ('model_id' , flat = True )
424- # 查询白名单授权的工具
425- white_authorized_tool_ids = QuerySet (model_workspace_authorization ).filter (
426- workspace_id = workspace_id , authentication_type = 'WHITE_LIST'
427- ).values_list ('model_id' , flat = True )
428- # 查询黑名单授权的工具
429- black_authorized_tool_ids = QuerySet (model_workspace_authorization ).filter (
430- workspace_id = workspace_id , authentication_type = 'BLACK_LIST'
431- ).values_list ('model_id' , flat = True )
432- tool_query_set = tool_query_set .filter (
433- id__in = list (white_authorized_tool_ids ) + list (all_auths )
434- ).exclude (
435- id__in = list (black_authorized_tool_ids ) + list (non_auths )
436- )
437- return tool_query_set
438-
439-
440415class WorkspaceSharedModelSerializer (serializers .Serializer ):
441416 workspace_id = serializers .CharField (required = True , label = _ ('workspace id' ))
442417 name = serializers .CharField (required = False , max_length = 64 , label = _ ('model name' ))
@@ -469,10 +444,9 @@ def get_share_model_list(self):
469444 def _build_queryset (self , workspace_id ):
470445 queryset = QuerySet (Model )
471446 if workspace_id :
472- model_workspace_authorization = DatabaseModelManage .get_model ("model_workspace_authorization" )
473- if model_workspace_authorization is not None :
474- queryset = get_authorized_tool (queryset , workspace_id ,
475- model_workspace_authorization = model_workspace_authorization )
447+ get_authorized_model = DatabaseModelManage .get_model ("get_authorized_model" )
448+ if get_authorized_model is not None :
449+ queryset = get_authorized_model (queryset , workspace_id )
476450
477451 for field in ['name' , 'model_type' , 'model_name' , 'provider' , 'create_user' ]:
478452 value = self .data .get (field )
0 commit comments