diff --git a/apiserver/plane/api/views/analytic.py b/apiserver/plane/api/views/analytic.py index a096c2700..e537af84a 100644 --- a/apiserver/plane/api/views/analytic.py +++ b/apiserver/plane/api/views/analytic.py @@ -3,6 +3,7 @@ from django.db.models import ( Count, Sum, F, + Q ) from django.db.models.functions import ExtractMonth @@ -59,10 +60,11 @@ class AnalyticsEndpoint(BaseAPIView): colors = ( State.objects.filter( + ~Q(name="Triage"), workspace__slug=slug, project_id__in=filters.get("project__in") ).values(key, "color") if filters.get("project__in", False) - else State.objects.filter(workspace__slug=slug).values(key, "color") + else State.objects.filter(~Q(name="Triage"), workspace__slug=slug).values(key, "color") ) if x_axis in ["labels__name"] or segment in ["labels__name"]: diff --git a/apiserver/plane/api/views/importer.py b/apiserver/plane/api/views/importer.py index e045a2ec1..28d490740 100644 --- a/apiserver/plane/api/views/importer.py +++ b/apiserver/plane/api/views/importer.py @@ -7,7 +7,7 @@ from rest_framework.response import Response from sentry_sdk import capture_exception # Django imports -from django.db.models import Max +from django.db.models import Max, Q # Module imports from plane.api.views import BaseAPIView @@ -309,11 +309,13 @@ class BulkImportIssuesEndpoint(BaseAPIView): # Get the default state default_state = State.objects.filter( - project_id=project_id, default=True + ~Q(name="Triage"), project_id=project_id, default=True ).first() # if there is no default state assign any random state if default_state is None: - default_state = State.objects.filter(project_id=project_id).first() + default_state = State.objects.filter( + ~Q(name="Triage"), sproject_id=project_id + ).first() # Get the maximum sequence_id last_id = IssueSequence.objects.filter(project_id=project_id).aggregate( diff --git a/apiserver/plane/api/views/issue.py b/apiserver/plane/api/views/issue.py index 35583fea2..fa7d9d6ec 100644 --- a/apiserver/plane/api/views/issue.py +++ b/apiserver/plane/api/views/issue.py @@ -607,7 +607,7 @@ class SubIssuesEndpoint(BaseAPIView): ) state_distribution = ( - State.objects.filter(workspace__slug=slug, project_id=project_id) + State.objects.filter(~Q(name="Triage"), workspace__slug=slug, project_id=project_id) .annotate( state_count=Count( "state_issue", diff --git a/apiserver/plane/api/views/state.py b/apiserver/plane/api/views/state.py index 29cba7a74..4fe0c8260 100644 --- a/apiserver/plane/api/views/state.py +++ b/apiserver/plane/api/views/state.py @@ -3,13 +3,13 @@ from itertools import groupby # Django imports from django.db import IntegrityError +from django.db.models import Q # Third party imports from rest_framework.response import Response from rest_framework import status from sentry_sdk import capture_exception - # Module imports from . import BaseViewSet, BaseAPIView from plane.api.serializers import StateSerializer @@ -34,6 +34,7 @@ class StateViewSet(BaseViewSet): .filter(workspace__slug=self.kwargs.get("slug")) .filter(project_id=self.kwargs.get("project_id")) .filter(project__project_projectmember__member=self.request.user) + .filter(~Q(name="Triage")) .select_related("project") .select_related("workspace") .distinct() @@ -80,7 +81,8 @@ class StateViewSet(BaseViewSet): def destroy(self, request, slug, project_id, pk): try: state = State.objects.get( - pk=pk, project_id=project_id, workspace__slug=slug + ~Q(name="Triage"), + pk=pk, project_id=project_id, workspace__slug=slug, ) if state.default: diff --git a/apiserver/plane/db/models/issue.py b/apiserver/plane/db/models/issue.py index 7efe86d46..1ecad6424 100644 --- a/apiserver/plane/db/models/issue.py +++ b/apiserver/plane/db/models/issue.py @@ -98,11 +98,13 @@ class Issue(ProjectBaseModel): from plane.db.models import State default_state = State.objects.filter( - project=self.project, default=True + ~models.Q(name="Triage"), project=self.project, default=True ).first() # if there is no default state assign any random state if default_state is None: - random_state = State.objects.filter(project=self.project).first() + random_state = State.objects.filter( + ~models.Q(name="Triage"), project=self.project + ).first() self.state = random_state if random_state.group == "started": self.start_date = timezone.now().date()