diff --git a/apps/api/plane/api/views/issue.py b/apps/api/plane/api/views/issue.py index 096a046302..b1d75fd17d 100644 --- a/apps/api/plane/api/views/issue.py +++ b/apps/api/plane/api/views/issue.py @@ -271,25 +271,6 @@ class WorkspaceIssueAPIEndpoint(BaseAPIView): Retrieve a specific work item using workspace slug, project identifier, and issue identifier. This endpoint provides workspace-level access to work items. """ - # ee start - # epics support - if request.GET.get("include_epics") == "true" and issue_identifier and project_identifier: - issue = Issue.issue_and_epics_objects.annotate( - sub_issues_count=Issue.issue_and_epics_objects.filter(parent=OuterRef("id")) - .order_by() - .annotate(count=Func(F("id"), function="Count")) - .values("count") - ).get( - workspace__slug=slug, - project__identifier=project_identifier, - sequence_id=issue_identifier, - ) - return Response( - IssueSerializer(issue, fields=self.fields, expand=self.expand).data, - status=status.HTTP_200_OK, - ) - # ee end - # Ensure labels and assignees are always expanded for issue details # this is required until we find a better way to create issue detail serializer expand = self.expand or [] @@ -297,15 +278,22 @@ class WorkspaceIssueAPIEndpoint(BaseAPIView): expand = list(set(expand) | required_expansions) if issue_identifier and project_identifier: - issue = Issue.issue_objects.annotate( - sub_issues_count=Issue.issue_objects.filter(parent=OuterRef("id")) - .order_by() - .annotate(count=Func(F("id"), function="Count")) - .values("count") - ).get( - workspace__slug=slug, - project__identifier=project_identifier, - sequence_id=issue_identifier, + # Use Issue.objects to support retrieving work items, + # epics, intake items, and drafts by identifier. + issue = ( + Issue.objects.exclude(archived_at__isnull=False) + .exclude(project__archived_at__isnull=False) + .annotate( + sub_issues_count=Issue.objects.filter(parent=OuterRef("id")) + .order_by() + .annotate(count=Func(F("id"), function="Count")) + .values("count"), + ) + .get( + workspace__slug=slug, + project__identifier=project_identifier, + sequence_id=issue_identifier, + ) ) return Response( IssueDetailSerializer(issue, fields=self.fields, expand=expand).data, diff --git a/apps/api/plane/tests/unit/ee/test_epic_endpoints.py b/apps/api/plane/tests/unit/ee/test_epic_endpoints.py index dd646bcd3e..32fd3c6992 100644 --- a/apps/api/plane/tests/unit/ee/test_epic_endpoints.py +++ b/apps/api/plane/tests/unit/ee/test_epic_endpoints.py @@ -31,7 +31,7 @@ class TestEpicEndpoints: assert response.data["id"] == epic.id def test_get_epic_by_identifier(self, api_key_client, workspace, project, epic, create_user): - """Test that an epic can be retrieved by identifier""" + """Test that an epic can be retrieved by identifier without include_epics param""" # Add user as project member to fix 403 error ProjectMember.objects.create(project=project, member=create_user, role=20, is_active=True) @@ -43,7 +43,6 @@ class TestEpicEndpoints: "issue_identifier": epic.sequence_id, }, ) - url += "?include_epics=true" response = api_key_client.get(url) assert response.status_code == status.HTTP_200_OK assert response.data["id"] == epic.id