(self)
| 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")) |
no test coverage detected