mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
dev: updated error handling for project deploy board attributes (#2062)
* dev: updated error handling for project deploy board attributes * dev: reaction integrity handling
This commit is contained in:
parent
63d799310b
commit
874d6e951b
@ -21,7 +21,7 @@ from django.db.models import (
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views.decorators.gzip import gzip_page
|
||||
from django.db.models.functions import Coalesce
|
||||
from django.db import IntegrityError
|
||||
from django.conf import settings
|
||||
|
||||
# Third Party imports
|
||||
@ -1545,6 +1545,7 @@ class IssueCommentPublicViewSet(BaseViewSet):
|
||||
return super(IssueCommentPublicViewSet, self).get_permissions()
|
||||
|
||||
def get_queryset(self):
|
||||
try:
|
||||
project_deploy_board = ProjectDeployBoard.objects.get(
|
||||
workspace__slug=self.kwargs.get("slug"),
|
||||
project_id=self.kwargs.get("project_id"),
|
||||
@ -1572,6 +1573,8 @@ class IssueCommentPublicViewSet(BaseViewSet):
|
||||
)
|
||||
else:
|
||||
return IssueComment.objects.none()
|
||||
except ProjectDeployBoard.DoesNotExist:
|
||||
return IssueComment.objects.none()
|
||||
|
||||
def create(self, request, slug, project_id, issue_id):
|
||||
try:
|
||||
@ -1703,6 +1706,7 @@ class IssueReactionPublicViewSet(BaseViewSet):
|
||||
model = IssueReaction
|
||||
|
||||
def get_queryset(self):
|
||||
try:
|
||||
project_deploy_board = ProjectDeployBoard.objects.get(
|
||||
workspace__slug=self.kwargs.get("slug"),
|
||||
project_id=self.kwargs.get("project_id"),
|
||||
@ -1719,6 +1723,8 @@ class IssueReactionPublicViewSet(BaseViewSet):
|
||||
)
|
||||
else:
|
||||
return IssueReaction.objects.none()
|
||||
except ProjectDeployBoard.DoesNotExist:
|
||||
return IssueReaction.objects.none()
|
||||
|
||||
def create(self, request, slug, project_id, issue_id):
|
||||
try:
|
||||
@ -1818,6 +1824,7 @@ class CommentReactionPublicViewSet(BaseViewSet):
|
||||
model = CommentReaction
|
||||
|
||||
def get_queryset(self):
|
||||
try:
|
||||
project_deploy_board = ProjectDeployBoard.objects.get(
|
||||
workspace__slug=self.kwargs.get("slug"),
|
||||
project_id=self.kwargs.get("project_id"),
|
||||
@ -1834,6 +1841,8 @@ class CommentReactionPublicViewSet(BaseViewSet):
|
||||
)
|
||||
else:
|
||||
return CommentReaction.objects.none()
|
||||
except ProjectDeployBoard.DoesNotExist:
|
||||
return CommentReaction.objects.none()
|
||||
|
||||
def create(self, request, slug, project_id, comment_id):
|
||||
try:
|
||||
@ -1939,6 +1948,12 @@ class IssueVotePublicViewSet(BaseViewSet):
|
||||
serializer_class = IssueVoteSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
try:
|
||||
project_deploy_board = ProjectDeployBoard.objects.get(
|
||||
workspace__slug=self.kwargs.get("slug"),
|
||||
project_id=self.kwargs.get("project_id"),
|
||||
)
|
||||
if project_deploy_board.votes:
|
||||
return (
|
||||
super()
|
||||
.get_queryset()
|
||||
@ -1946,6 +1961,10 @@ class IssueVotePublicViewSet(BaseViewSet):
|
||||
.filter(workspace__slug=self.kwargs.get("slug"))
|
||||
.filter(project_id=self.kwargs.get("project_id"))
|
||||
)
|
||||
else:
|
||||
return IssueVote.objects.none()
|
||||
except ProjectDeployBoard.DoesNotExist:
|
||||
return IssueVote.objects.none()
|
||||
|
||||
def create(self, request, slug, project_id, issue_id):
|
||||
try:
|
||||
@ -1974,6 +1993,8 @@ class IssueVotePublicViewSet(BaseViewSet):
|
||||
)
|
||||
serializer = IssueVoteSerializer(issue_vote)
|
||||
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
||||
except IntegrityError:
|
||||
return Response({"error": "Reaction already exists"}, status=status.HTTP_400_BAD_REQUEST)
|
||||
except Exception as e:
|
||||
capture_exception(e)
|
||||
return Response(
|
||||
|
Loading…
Reference in New Issue
Block a user