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

Method download

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

Source from the content-addressed store, hash-verified

1543 tool_id = serializers.CharField(required=True, label=_("tool id"))
1544
1545 def download(self):
1546 self.is_valid(raise_exception=True)
1547 tool = (
1548 QuerySet(Tool)
1549 .filter(
1550 id=self.data.get("tool_id"), workspace_id=self.data.get("workspace_id"), tool_type=ToolType.SKILL
1551 )
1552 .first()
1553 )
1554
1555 if tool is None:
1556 raise AppApiException(500, _("Tool does not exist"))
1557 skill_file = QuerySet(File).filter(id=tool.code).first()
1558 if skill_file is None:
1559 raise AppApiException(500, _("Skill file does not exist"))
1560
1561 response = HttpResponse(content_type="application/zip", content=skill_file.get_bytes())
1562 response["Content-Disposition"] = f'attachment; filename="{skill_file.file_name}"'
1563 return response
1564
1565 class GenerateCodeSerializer(serializers.Serializer):
1566 workspace_id = serializers.CharField(required=True, label=_("Workspace ID"))

Callers 2

getMethod · 0.80
generate_videoMethod · 0.80

Calls 4

AppApiExceptionClass · 0.90
get_bytesMethod · 0.80
is_validMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected