chore: endpoint changes

This commit is contained in:
NarayanBavisetti 2024-06-04 19:17:56 +05:30
parent bd58931690
commit 9f36d8158a
8 changed files with 144 additions and 108 deletions

View File

@ -674,7 +674,8 @@ class DeployBoardViewSet(BaseViewSet):
)
project_deploy_board, _ = DeployBoard.objects.get_or_create(
anchor=f"{slug}/{project_id}",
entity_name="project",
entity_identifier=project_id,
project_id=project_id,
)
project_deploy_board.comments = comments

View File

@ -10,7 +10,7 @@ from plane.space.views import (
urlpatterns = [
path(
"workspaces/<str:slug>/project-boards/<uuid:project_id>/inboxes/<uuid:inbox_id>/inbox-issues/",
"anchor/<uuid:anchor_id>/inboxes/<uuid:inbox_id>/inbox-issues/",
InboxIssuePublicViewSet.as_view(
{
"get": "list",
@ -20,7 +20,7 @@ urlpatterns = [
name="inbox-issue",
),
path(
"workspaces/<str:slug>/project-boards/<uuid:project_id>/inboxes/<uuid:inbox_id>/inbox-issues/<uuid:pk>/",
"anchor/<uuid:anchor_id>/inboxes/<uuid:inbox_id>/inbox-issues/<uuid:pk>/",
InboxIssuePublicViewSet.as_view(
{
"get": "retrieve",
@ -31,7 +31,7 @@ urlpatterns = [
name="inbox-issue",
),
path(
"workspaces/<str:slug>/project-boards/<uuid:project_id>/issues/<uuid:issue_id>/votes/",
"anchor/<uuid:anchor_id>/issues/<uuid:issue_id>/votes/",
IssueVotePublicViewSet.as_view(
{
"get": "list",

View File

@ -10,12 +10,12 @@ from plane.space.views import (
urlpatterns = [
path(
"workspaces/<str:slug>/project-boards/<uuid:project_id>/issues/<uuid:issue_id>/",
"anchor/<uuid:anchor_id>/issues/<uuid:issue_id>/",
IssueRetrievePublicEndpoint.as_view(),
name="workspace-project-boards",
),
path(
"workspaces/<str:slug>/project-boards/<uuid:project_id>/issues/<uuid:issue_id>/comments/",
"anchor/<uuid:anchor_id>/issues/<uuid:issue_id>/comments/",
IssueCommentPublicViewSet.as_view(
{
"get": "list",
@ -25,7 +25,7 @@ urlpatterns = [
name="issue-comments-project-board",
),
path(
"workspaces/<str:slug>/project-boards/<uuid:project_id>/issues/<uuid:issue_id>/comments/<uuid:pk>/",
"anchor/<uuid:anchor_id>/issues/<uuid:issue_id>/comments/<uuid:pk>/",
IssueCommentPublicViewSet.as_view(
{
"get": "retrieve",
@ -36,7 +36,7 @@ urlpatterns = [
name="issue-comments-project-board",
),
path(
"workspaces/<str:slug>/project-boards/<uuid:project_id>/issues/<uuid:issue_id>/reactions/",
"anchor/<uuid:anchor_id>/issues/<uuid:issue_id>/reactions/",
IssueReactionPublicViewSet.as_view(
{
"get": "list",
@ -46,7 +46,7 @@ urlpatterns = [
name="issue-reactions-project-board",
),
path(
"workspaces/<str:slug>/project-boards/<uuid:project_id>/issues/<uuid:issue_id>/reactions/<str:reaction_code>/",
"anchor/<uuid:anchor_id>/issues/<uuid:issue_id>/reactions/<str:reaction_code>/",
IssueReactionPublicViewSet.as_view(
{
"delete": "destroy",
@ -55,7 +55,7 @@ urlpatterns = [
name="issue-reactions-project-board",
),
path(
"workspaces/<str:slug>/project-boards/<uuid:project_id>/comments/<uuid:comment_id>/reactions/",
"anchor/<uuid:anchor_id>/comments/<uuid:comment_id>/reactions/",
CommentReactionPublicViewSet.as_view(
{
"get": "list",
@ -65,7 +65,7 @@ urlpatterns = [
name="comment-reactions-project-board",
),
path(
"workspaces/<str:slug>/project-boards/<uuid:project_id>/comments/<uuid:comment_id>/reactions/<str:reaction_code>/",
"anchor/<uuid:anchor_id>/comments/<uuid:comment_id>/reactions/<str:reaction_code>/",
CommentReactionPublicViewSet.as_view(
{
"delete": "destroy",

View File

@ -4,17 +4,23 @@ from django.urls import path
from plane.space.views import (
ProjectDeployBoardPublicSettingsEndpoint,
ProjectIssuesPublicEndpoint,
WorkspaceProjectAnchorEndpoint,
)
urlpatterns = [
path(
"workspaces/<str:slug>/project-boards/<uuid:project_id>/settings/",
"anchor/<uuid:anchor_id>/settings/",
ProjectDeployBoardPublicSettingsEndpoint.as_view(),
name="project-deploy-board-settings",
),
path(
"workspaces/<str:slug>/project-boards/<uuid:project_id>/issues/",
"anchor/<uuid:anchor_id>/issues/",
ProjectIssuesPublicEndpoint.as_view(),
name="project-deploy-board",
),
path(
"workspaces/<str:slug>/projects/<uuid:project_id>/anchor/",
WorkspaceProjectAnchorEndpoint.as_view(),
name="project-deploy-board",
),
]

View File

@ -1,6 +1,7 @@
from .project import (
ProjectDeployBoardPublicSettingsEndpoint,
WorkspaceProjectDeployBoardEndpoint,
WorkspaceProjectAnchorEndpoint,
)
from .issue import (

View File

@ -58,9 +58,9 @@ class InboxIssuePublicViewSet(BaseViewSet):
)
return InboxIssue.objects.none()
def list(self, request, slug, project_id, inbox_id):
def list(self, request, anchor, inbox_id):
project_deploy_board = DeployBoard.objects.get(
workspace__slug=slug, project_id=project_id
anchor=anchor, entity_name="project"
)
if project_deploy_board.inbox is None:
return Response(
@ -72,8 +72,8 @@ class InboxIssuePublicViewSet(BaseViewSet):
issues = (
Issue.objects.filter(
issue_inbox__inbox_id=inbox_id,
workspace__slug=slug,
project_id=project_id,
workspace_id=project_deploy_board.workspace_id,
project_id=project_deploy_board.project_id,
)
.filter(**filters)
.annotate(bridge_id=F("issue_inbox__id"))
@ -117,9 +117,9 @@ class InboxIssuePublicViewSet(BaseViewSet):
status=status.HTTP_200_OK,
)
def create(self, request, slug, project_id, inbox_id):
def create(self, request, anchor, inbox_id):
project_deploy_board = DeployBoard.objects.get(
workspace__slug=slug, project_id=project_id
anchor=anchor, entity_name="project"
)
if project_deploy_board.inbox is None:
return Response(
@ -151,7 +151,7 @@ class InboxIssuePublicViewSet(BaseViewSet):
name="Triage",
group="backlog",
description="Default state for managing all Inbox Issues",
project_id=project_id,
project_id=project_deploy_board.project_id,
color="#ff7700",
)
@ -163,7 +163,7 @@ class InboxIssuePublicViewSet(BaseViewSet):
"description_html", "<p></p>"
),
priority=request.data.get("issue", {}).get("priority", "low"),
project_id=project_id,
project_id=project_deploy_board.project_id,
state=state,
)
@ -173,14 +173,14 @@ class InboxIssuePublicViewSet(BaseViewSet):
requested_data=json.dumps(request.data, cls=DjangoJSONEncoder),
actor_id=str(request.user.id),
issue_id=str(issue.id),
project_id=str(project_id),
project_id=str(project_deploy_board.project_id),
current_instance=None,
epoch=int(timezone.now().timestamp()),
)
# create an inbox issue
InboxIssue.objects.create(
inbox_id=inbox_id,
project_id=project_id,
project_id=project_deploy_board.project_id,
issue=issue,
source=request.data.get("source", "in-app"),
)
@ -188,9 +188,9 @@ class InboxIssuePublicViewSet(BaseViewSet):
serializer = IssueStateInboxSerializer(issue)
return Response(serializer.data, status=status.HTTP_200_OK)
def partial_update(self, request, slug, project_id, inbox_id, pk):
def partial_update(self, request, anchor, inbox_id, pk):
project_deploy_board = DeployBoard.objects.get(
workspace__slug=slug, project_id=project_id
anchor=anchor, entity_name="project"
)
if project_deploy_board.inbox is None:
return Response(
@ -200,8 +200,8 @@ class InboxIssuePublicViewSet(BaseViewSet):
inbox_issue = InboxIssue.objects.get(
pk=pk,
workspace__slug=slug,
project_id=project_id,
workspace_id=project_deploy_board.workspace_id,
project_id=project_deploy_board.project_id,
inbox_id=inbox_id,
)
# Get the project member
@ -216,8 +216,8 @@ class InboxIssuePublicViewSet(BaseViewSet):
issue = Issue.objects.get(
pk=inbox_issue.issue_id,
workspace__slug=slug,
project_id=project_id,
workspace_id=project_deploy_board.workspace_id,
project_id=project_deploy_board.project_id,
)
# viewers and guests since only viewers and guests
issue_data = {
@ -242,7 +242,7 @@ class InboxIssuePublicViewSet(BaseViewSet):
requested_data=requested_data,
actor_id=str(request.user.id),
issue_id=str(issue.id),
project_id=str(project_id),
project_id=str(project_deploy_board.project_id),
current_instance=json.dumps(
IssueSerializer(current_instance).data,
cls=DjangoJSONEncoder,
@ -255,9 +255,9 @@ class InboxIssuePublicViewSet(BaseViewSet):
issue_serializer.errors, status=status.HTTP_400_BAD_REQUEST
)
def retrieve(self, request, slug, project_id, inbox_id, pk):
def retrieve(self, request, anchor, inbox_id, pk):
project_deploy_board = DeployBoard.objects.get(
workspace__slug=slug, project_id=project_id
anchor=anchor, entity_name="project"
)
if project_deploy_board.inbox is None:
return Response(
@ -267,21 +267,21 @@ class InboxIssuePublicViewSet(BaseViewSet):
inbox_issue = InboxIssue.objects.get(
pk=pk,
workspace__slug=slug,
project_id=project_id,
workspace_id=project_deploy_board.workspace_id,
project_id=project_deploy_board.project_id,
inbox_id=inbox_id,
)
issue = Issue.objects.get(
pk=inbox_issue.issue_id,
workspace__slug=slug,
project_id=project_id,
workspace_id=project_deploy_board.workspace_id,
project_id=project_deploy_board.project_id,
)
serializer = IssueStateInboxSerializer(issue)
return Response(serializer.data, status=status.HTTP_200_OK)
def destroy(self, request, slug, project_id, inbox_id, pk):
def destroy(self, request, anchor, inbox_id, pk):
project_deploy_board = DeployBoard.objects.get(
workspace__slug=slug, project_id=project_id
anchor=anchor, entity_name="project"
)
if project_deploy_board.inbox is None:
return Response(
@ -291,8 +291,8 @@ class InboxIssuePublicViewSet(BaseViewSet):
inbox_issue = InboxIssue.objects.get(
pk=pk,
workspace__slug=slug,
project_id=project_id,
workspace_id=project_deploy_board.workspace_id,
project_id=project_deploy_board.project_id,
inbox_id=inbox_id,
)

View File

@ -106,9 +106,9 @@ class IssueCommentPublicViewSet(BaseViewSet):
except DeployBoard.DoesNotExist:
return IssueComment.objects.none()
def create(self, request, slug, project_id, issue_id):
def create(self, request, anchor, issue_id):
project_deploy_board = DeployBoard.objects.get(
workspace__slug=slug, project_id=project_id
anchor=anchor, entity_name="project"
)
if not project_deploy_board.comments:
@ -120,7 +120,7 @@ class IssueCommentPublicViewSet(BaseViewSet):
serializer = IssueCommentSerializer(data=request.data)
if serializer.is_valid():
serializer.save(
project_id=project_id,
project_id=project_deploy_board.project_id,
issue_id=issue_id,
actor=request.user,
access="EXTERNAL",
@ -132,27 +132,27 @@ class IssueCommentPublicViewSet(BaseViewSet):
),
actor_id=str(request.user.id),
issue_id=str(issue_id),
project_id=str(project_id),
project_id=str(project_deploy_board.project_id),
current_instance=None,
epoch=int(timezone.now().timestamp()),
)
if not ProjectMember.objects.filter(
project_id=project_id,
project_id=project_deploy_board.project_id,
member=request.user,
is_active=True,
).exists():
# Add the user for workspace tracking
_ = ProjectPublicMember.objects.get_or_create(
project_id=project_id,
project_id=project_deploy_board.project_id,
member=request.user,
)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def partial_update(self, request, slug, project_id, issue_id, pk):
def partial_update(self, request, anchor, issue_id, pk):
project_deploy_board = DeployBoard.objects.get(
workspace__slug=slug, project_id=project_id
anchor=anchor, entity_name="project"
)
if not project_deploy_board.comments:
@ -160,9 +160,7 @@ class IssueCommentPublicViewSet(BaseViewSet):
{"error": "Comments are not enabled for this project"},
status=status.HTTP_400_BAD_REQUEST,
)
comment = IssueComment.objects.get(
workspace__slug=slug, pk=pk, actor=request.user
)
comment = IssueComment.objects.get(pk=pk, actor=request.user)
serializer = IssueCommentSerializer(
comment, data=request.data, partial=True
)
@ -173,7 +171,7 @@ class IssueCommentPublicViewSet(BaseViewSet):
requested_data=json.dumps(request.data, cls=DjangoJSONEncoder),
actor_id=str(request.user.id),
issue_id=str(issue_id),
project_id=str(project_id),
project_id=str(project_deploy_board.project_id),
current_instance=json.dumps(
IssueCommentSerializer(comment).data,
cls=DjangoJSONEncoder,
@ -183,9 +181,9 @@ class IssueCommentPublicViewSet(BaseViewSet):
return Response(serializer.data, status=status.HTTP_200_OK)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def destroy(self, request, slug, project_id, issue_id, pk):
def destroy(self, request, anchor, issue_id, pk):
project_deploy_board = DeployBoard.objects.get(
workspace__slug=slug, project_id=project_id
anchor=anchor, entity_name="project"
)
if not project_deploy_board.comments:
@ -194,9 +192,7 @@ class IssueCommentPublicViewSet(BaseViewSet):
status=status.HTTP_400_BAD_REQUEST,
)
comment = IssueComment.objects.get(
workspace__slug=slug,
pk=pk,
project_id=project_id,
actor=request.user,
)
issue_activity.delay(
@ -204,7 +200,7 @@ class IssueCommentPublicViewSet(BaseViewSet):
requested_data=json.dumps({"comment_id": str(pk)}),
actor_id=str(request.user.id),
issue_id=str(issue_id),
project_id=str(project_id),
project_id=str(project_deploy_board.project_id),
current_instance=json.dumps(
IssueCommentSerializer(comment).data,
cls=DjangoJSONEncoder,
@ -239,9 +235,9 @@ class IssueReactionPublicViewSet(BaseViewSet):
except DeployBoard.DoesNotExist:
return IssueReaction.objects.none()
def create(self, request, slug, project_id, issue_id):
def create(self, request, anchor, issue_id):
project_deploy_board = DeployBoard.objects.get(
workspace__slug=slug, project_id=project_id
anchor=anchor, entity_name="project"
)
if not project_deploy_board.reactions:
@ -253,16 +249,18 @@ class IssueReactionPublicViewSet(BaseViewSet):
serializer = IssueReactionSerializer(data=request.data)
if serializer.is_valid():
serializer.save(
project_id=project_id, issue_id=issue_id, actor=request.user
project_id=project_deploy_board.project_id,
issue_id=issue_id,
actor=request.user,
)
if not ProjectMember.objects.filter(
project_id=project_id,
project_id=project_deploy_board.project_id,
member=request.user,
is_active=True,
).exists():
# Add the user for workspace tracking
_ = ProjectPublicMember.objects.get_or_create(
project_id=project_id,
project_id=project_deploy_board.project_id,
member=request.user,
)
issue_activity.delay(
@ -272,16 +270,16 @@ class IssueReactionPublicViewSet(BaseViewSet):
),
actor_id=str(self.request.user.id),
issue_id=str(self.kwargs.get("issue_id", None)),
project_id=str(self.kwargs.get("project_id", None)),
project_id=str(project_deploy_board.project_id),
current_instance=None,
epoch=int(timezone.now().timestamp()),
)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def destroy(self, request, slug, project_id, issue_id, reaction_code):
def destroy(self, request, anchor, issue_id, reaction_code):
project_deploy_board = DeployBoard.objects.get(
workspace__slug=slug, project_id=project_id
anchor=anchor, entity_name="project"
)
if not project_deploy_board.reactions:
@ -290,7 +288,7 @@ class IssueReactionPublicViewSet(BaseViewSet):
status=status.HTTP_400_BAD_REQUEST,
)
issue_reaction = IssueReaction.objects.get(
workspace__slug=slug,
workspace_id=project_deploy_board.workspace_id,
issue_id=issue_id,
reaction=reaction_code,
actor=request.user,
@ -300,7 +298,7 @@ class IssueReactionPublicViewSet(BaseViewSet):
requested_data=None,
actor_id=str(self.request.user.id),
issue_id=str(self.kwargs.get("issue_id", None)),
project_id=str(self.kwargs.get("project_id", None)),
project_id=str(project_deploy_board.project_id),
current_instance=json.dumps(
{
"reaction": str(reaction_code),
@ -320,15 +318,14 @@ class CommentReactionPublicViewSet(BaseViewSet):
def get_queryset(self):
try:
project_deploy_board = DeployBoard.objects.get(
workspace__slug=self.kwargs.get("slug"),
project_id=self.kwargs.get("project_id"),
anchor=self.kwargs.get("anchor"), entity_name="project"
)
if project_deploy_board.reactions:
return (
super()
.get_queryset()
.filter(workspace__slug=self.kwargs.get("slug"))
.filter(project_id=self.kwargs.get("project_id"))
.filter(workspace_id=project_deploy_board.workspace_id)
.filter(project_id=project_deploy_board.project_id)
.filter(comment_id=self.kwargs.get("comment_id"))
.order_by("-created_at")
.distinct()
@ -337,9 +334,9 @@ class CommentReactionPublicViewSet(BaseViewSet):
except DeployBoard.DoesNotExist:
return CommentReaction.objects.none()
def create(self, request, slug, project_id, comment_id):
def create(self, request, anchor, comment_id):
project_deploy_board = DeployBoard.objects.get(
workspace__slug=slug, project_id=project_id
anchor=anchor, entity_name="project"
)
if not project_deploy_board.reactions:
@ -351,18 +348,18 @@ class CommentReactionPublicViewSet(BaseViewSet):
serializer = CommentReactionSerializer(data=request.data)
if serializer.is_valid():
serializer.save(
project_id=project_id,
project_id=project_deploy_board.project_id,
comment_id=comment_id,
actor=request.user,
)
if not ProjectMember.objects.filter(
project_id=project_id,
project_id=project_deploy_board.project_id,
member=request.user,
is_active=True,
).exists():
# Add the user for workspace tracking
_ = ProjectPublicMember.objects.get_or_create(
project_id=project_id,
project_id=project_deploy_board.project_id,
member=request.user,
)
issue_activity.delay(
@ -379,9 +376,9 @@ class CommentReactionPublicViewSet(BaseViewSet):
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def destroy(self, request, slug, project_id, comment_id, reaction_code):
def destroy(self, request, anchor, comment_id, reaction_code):
project_deploy_board = DeployBoard.objects.get(
workspace__slug=slug, project_id=project_id
anchor=anchor, entity_name="project"
)
if not project_deploy_board.reactions:
return Response(
@ -390,8 +387,8 @@ class CommentReactionPublicViewSet(BaseViewSet):
)
comment_reaction = CommentReaction.objects.get(
project_id=project_id,
workspace__slug=slug,
project_id=project_deploy_board.project_id,
workspace_id=project_deploy_board.workspace_id,
comment_id=comment_id,
reaction=reaction_code,
actor=request.user,
@ -401,7 +398,7 @@ class CommentReactionPublicViewSet(BaseViewSet):
requested_data=None,
actor_id=str(self.request.user.id),
issue_id=None,
project_id=str(self.kwargs.get("project_id", None)),
project_id=str(project_deploy_board.project_id),
current_instance=json.dumps(
{
"reaction": str(reaction_code),
@ -422,35 +419,37 @@ class IssueVotePublicViewSet(BaseViewSet):
def get_queryset(self):
try:
project_deploy_board = DeployBoard.objects.get(
workspace__slug=self.kwargs.get("slug"),
project_id=self.kwargs.get("project_id"),
workspace__slug=self.kwargs.get("anchor"),
entity_name="project",
)
if project_deploy_board.votes:
return (
super()
.get_queryset()
.filter(issue_id=self.kwargs.get("issue_id"))
.filter(workspace__slug=self.kwargs.get("slug"))
.filter(project_id=self.kwargs.get("project_id"))
.filter(workspace_id=project_deploy_board.workspace_id)
.filter(project_id=project_deploy_board.project_id)
)
return IssueVote.objects.none()
except DeployBoard.DoesNotExist:
return IssueVote.objects.none()
def create(self, request, slug, project_id, issue_id):
def create(self, request, anchor, issue_id):
project_deploy_board = DeployBoard.objects.get(
anchor=anchor, entity_name="project"
)
issue_vote, _ = IssueVote.objects.get_or_create(
actor_id=request.user.id,
project_id=project_id,
issue_id=issue_id,
)
# Add the user for workspace tracking
if not ProjectMember.objects.filter(
project_id=project_id,
project_id=project_deploy_board.project_id,
member=request.user,
is_active=True,
).exists():
_ = ProjectPublicMember.objects.get_or_create(
project_id=project_id,
project_id=project_deploy_board.project_id,
member=request.user,
)
issue_vote.vote = request.data.get("vote", 1)
@ -462,26 +461,29 @@ class IssueVotePublicViewSet(BaseViewSet):
),
actor_id=str(self.request.user.id),
issue_id=str(self.kwargs.get("issue_id", None)),
project_id=str(self.kwargs.get("project_id", None)),
project_id=str(project_deploy_board.project_id),
current_instance=None,
epoch=int(timezone.now().timestamp()),
)
serializer = IssueVoteSerializer(issue_vote)
return Response(serializer.data, status=status.HTTP_201_CREATED)
def destroy(self, request, slug, project_id, issue_id):
def destroy(self, request, anchor, issue_id):
project_deploy_board = DeployBoard.objects.get(
anchor=anchor, entity_name="project"
)
issue_vote = IssueVote.objects.get(
workspace__slug=slug,
project_id=project_id,
issue_id=issue_id,
actor_id=request.user.id,
project_id=project_deploy_board.project_id,
workspace_id=project_deploy_board.workspace_id,
)
issue_activity.delay(
type="issue_vote.activity.deleted",
requested_data=None,
actor_id=str(self.request.user.id),
issue_id=str(self.kwargs.get("issue_id", None)),
project_id=str(self.kwargs.get("project_id", None)),
project_id=str(project_deploy_board.project_id),
current_instance=json.dumps(
{
"vote": str(issue_vote.vote),
@ -499,9 +501,14 @@ class IssueRetrievePublicEndpoint(BaseAPIView):
AllowAny,
]
def get(self, request, slug, project_id, issue_id):
def get(self, request, anchor, issue_id):
project_deploy_board = DeployBoard.objects.get(
anchor=anchor, entity_name="project"
)
issue = Issue.objects.get(
workspace__slug=slug, project_id=project_id, pk=issue_id
workspace_id=project_deploy_board.workspace_id,
project_id=project_deploy_board.project_id,
pk=issue_id,
)
serializer = IssuePublicSerializer(issue)
return Response(serializer.data, status=status.HTTP_200_OK)
@ -512,14 +519,17 @@ class ProjectIssuesPublicEndpoint(BaseAPIView):
AllowAny,
]
def get(self, request, slug, project_id):
def get(self, request, anchor):
if not DeployBoard.objects.filter(
workspace__slug=slug, project_id=project_id
anchor=anchor, entity_name="project"
).exists():
return Response(
{"error": "Project is not published"},
status=status.HTTP_404_NOT_FOUND,
)
project_deploy_board = DeployBoard.objects.get(
anchor=anchor, entity_name="project"
)
filters = issue_filters(request.query_params, "GET")
@ -544,8 +554,8 @@ class ProjectIssuesPublicEndpoint(BaseAPIView):
.annotate(count=Func(F("id"), function="Count"))
.values("count")
)
.filter(project_id=project_id)
.filter(workspace__slug=slug)
.filter(project_id=project_deploy_board.project_id)
.filter(workspace_id=project_deploy_board.workspace_id)
.select_related("project", "workspace", "state", "parent")
.prefetch_related("assignees", "labels")
.prefetch_related(
@ -652,8 +662,8 @@ class ProjectIssuesPublicEndpoint(BaseAPIView):
states = (
State.objects.filter(
~Q(name="Triage"),
workspace__slug=slug,
project_id=project_id,
workspace_id=project_deploy_board.workspace_id,
project_id=project_deploy_board.project_id,
)
.annotate(
custom_order=Case(
@ -670,7 +680,8 @@ class ProjectIssuesPublicEndpoint(BaseAPIView):
)
labels = Label.objects.filter(
workspace__slug=slug, project_id=project_id
workspace_id=project_deploy_board.workspace_id,
project_id=project_deploy_board.project_id,
).values("id", "name", "color", "parent")
## Grouping the results

View File

@ -23,9 +23,9 @@ class ProjectDeployBoardPublicSettingsEndpoint(BaseAPIView):
AllowAny,
]
def get(self, request, slug, project_id):
def get(self, request, anchor):
project_deploy_board = DeployBoard.objects.get(
workspace__slug=slug, project_id=project_id
anchor=anchor, entity_name="project"
)
serializer = DeployBoardSerializer(project_deploy_board)
return Response(serializer.data, status=status.HTTP_200_OK)
@ -36,13 +36,16 @@ class WorkspaceProjectDeployBoardEndpoint(BaseAPIView):
AllowAny,
]
def get(self, request, slug):
def get(self, request, anchor):
deploy_board = DeployBoard.objects.filter(anchor=anchor, entity_name="project").values_list
projects = (
Project.objects.filter(workspace__slug=slug)
Project.objects.filter(workspace=deploy_board.workspace)
.annotate(
is_public=Exists(
DeployBoard.objects.filter(
workspace__slug=slug, project_id=OuterRef("pk")
anchor=anchor,
project_id=OuterRef("pk"),
entity_name="project",
)
)
)
@ -58,3 +61,17 @@ class WorkspaceProjectDeployBoardEndpoint(BaseAPIView):
)
return Response(projects, status=status.HTTP_200_OK)
class WorkspaceProjectAnchorEndpoint(BaseAPIView):
permission_classes = [
AllowAny,
]
def get(self, request, slug, project_id):
print("did it come here")
project_deploy_board = DeployBoard.objects.get(
workspace__slug=slug, project_id=project_id
)
serializer = DeployBoardSerializer(project_deploy_board)
return Response(serializer.data, status=status.HTTP_200_OK)