MCPcopy
hub / github.com/1Panel-dev/MaxKB / one

Method one

apps/tools/serializers/tool.py:729–766  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

727 deploy(TriggerModelSerializer(trigger).data, **{})
728
729 def one(self):
730 self.is_one_valid(raise_exception=True)
731 tool = QuerySet(Tool).filter(id=self.data.get("id")).select_related("user").first()
732 nick_name = tool.user.nick_name if tool and tool.user else None
733 if tool.init_params:
734 tool.init_params = json.loads(rsa_long_decrypt(tool.init_params))
735 if tool.init_field_list:
736 password_fields = [i["field"] for i in tool.init_field_list if i.get("input_type") == "PasswordInput"]
737 if tool.init_params:
738 for k in tool.init_params:
739 if k in password_fields and tool.init_params[k]:
740 tool.init_params[k] = encryption(tool.init_params[k])
741 if tool.tool_type == "SKILL":
742 skill_file = QuerySet(File).filter(id=tool.code).first()
743 skill_file_dict = (
744 {
745 "id": str(skill_file.id),
746 "name": skill_file.file_name,
747 "size": skill_file.file_size,
748 }
749 if skill_file
750 else None
751 )
752 work_flow = {}
753 is_publish = False
754 if tool.tool_type == "WORKFLOW":
755 tool_workflow = QuerySet(ToolWorkflow).filter(tool_id=tool.id).first()
756 if tool_workflow:
757 work_flow = tool_workflow.work_flow
758 is_publish = tool_workflow.is_publish
759 return {
760 **ToolModelSerializer(tool).data,
761 "init_params": tool.init_params if tool.init_params else {},
762 "nick_name": nick_name,
763 "fileList": [skill_file_dict] if tool.tool_type == "SKILL" else [],
764 "work_flow": work_flow,
765 "is_publish": is_publish,
766 }
767
768 def get_child_tool_list(self, work_flow, response):
769 from application.flow.tools import get_tool_id_list

Callers 8

editMethod · 0.95
insertMethod · 0.45
import_Method · 0.45
getMethod · 0.45
getMethod · 0.45
getMethod · 0.45
getMethod · 0.45
getMethod · 0.45

Calls 5

is_one_validMethod · 0.95
rsa_long_decryptFunction · 0.90
ToolModelSerializerClass · 0.85
encryptionFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected