[WEB-6528] fix: External API returns 404 when retrieving an epic by work item identifier (#6196)
* fix: allow epics in work item identifier endpoint * fix: allow intake work items as well * fix: remove is_epic and is_intake * fix: remove unused imports * fix: update the tests
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user