|
45 | 45 | from system_manage.models import WorkspaceUserResourcePermission, AuthTargetType
|
46 | 46 | from system_manage.serializers.user_resource_permission import UserResourcePermissionSerializer
|
47 | 47 | from tools.models import Tool, ToolScope
|
48 |
| -from tools.serializers.tool import ToolModelSerializer |
| 48 | +from tools.serializers.tool import ToolExportModelSerializer |
49 | 49 | from users.models import User
|
50 | 50 | from users.serializers.user import is_workspace_manage
|
51 | 51 |
|
@@ -554,14 +554,15 @@ def to_tool(tool, workspace_id, user_id):
|
554 | 554 | @param tool: 工具
|
555 | 555 | @return:
|
556 | 556 | """
|
| 557 | + |
557 | 558 | return Tool(id=tool.get('id'),
|
558 | 559 | user_id=user_id,
|
559 | 560 | name=tool.get('name'),
|
560 | 561 | code=tool.get('code'),
|
561 | 562 | template_id=tool.get('template_id'),
|
562 | 563 | input_field_list=tool.get('input_field_list'),
|
563 | 564 | init_field_list=tool.get('init_field_list'),
|
564 |
| - is_active=tool.get('is_active'), |
| 565 | + is_active=tool.get('is_active') if len((tool.get('init_field_list') or [])) > 0 else False, |
565 | 566 | scope=ToolScope.WORKSPACE,
|
566 | 567 | folder_id=workspace_id,
|
567 | 568 | workspace_id=workspace_id)
|
@@ -682,7 +683,7 @@ def export(self, with_valid=True):
|
682 | 683 | mk_instance = MKInstance(application_dict,
|
683 | 684 | [],
|
684 | 685 | 'v2',
|
685 |
| - [ToolModelSerializer(tool).data for tool in |
| 686 | + [ToolExportModelSerializer(tool).data for tool in |
686 | 687 | tool_list])
|
687 | 688 | application_pickle = pickle.dumps(mk_instance)
|
688 | 689 | response = HttpResponse(content_type='text/plain', content=application_pickle)
|
|
0 commit comments