(self, *, raise_exception=False)
| 588 | document_id = serializers.UUIDField(required=True, label=_("document id")) |
| 589 | |
| 590 | def is_valid(self, *, raise_exception=False): |
| 591 | super().is_valid(raise_exception=True) |
| 592 | workspace_id = self.data.get("workspace_id") |
| 593 | query_set = QuerySet(Knowledge).filter(id=self.data.get("knowledge_id")) |
| 594 | if workspace_id: |
| 595 | query_set = query_set.filter(workspace_id=workspace_id) |
| 596 | if not query_set.exists(): |
| 597 | raise AppApiException(500, _("Knowledge id does not exist")) |
| 598 | document_id = self.data.get("document_id") |
| 599 | first = QuerySet(Document).filter(id=document_id).first() |
| 600 | if first is None: |
| 601 | raise AppApiException(500, _("document id not exist")) |
| 602 | if first.type != KnowledgeType.WEB: |
| 603 | raise AppApiException(500, _("Synchronization is only supported for web site types")) |
| 604 | |
| 605 | @transaction.atomic |
| 606 | def sync(self, with_valid=True, with_embedding=True): |
no test coverage detected