Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/api/plane/app/views/cycle/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ def get_queryset(self):
Q(
issue_cycle__issue__issue_assignee__deleted_at__isnull=True
)
)
& Q(
issue_cycle__issue__assignees__member_project__project_id=self.kwargs.get(
"project_id"
)
)
& Q(
issue_cycle__issue__assignees__member_project__is_active=True
),
),
Value([], output_field=ArrayField(UUIDField())),
Expand Down
3 changes: 3 additions & 0 deletions apps/api/plane/app/views/issue/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ def retrieve(self, request, slug, project_id, pk=None):
filter=Q(
~Q(assignees__id__isnull=True)
& Q(assignees__member_project__is_active=True)
& Q(assignees__member_project__project_id=project_id)
& Q(issue_assignee__deleted_at__isnull=True)
),
),
Expand Down Expand Up @@ -914,6 +915,7 @@ def list(self, request, slug, project_id):
~Q(assignees__id__isnull=True)
& Q(assignees__member_project__is_active=True)
& Q(issue_assignee__deleted_at__isnull=True)
& Q(assignees__member_project__project_id=project_id)
),
),
Value([], output_field=ArrayField(UUIDField())),
Expand Down Expand Up @@ -1253,6 +1255,7 @@ def get(self, request, slug, project_identifier, issue_identifier):
~Q(assignees__id__isnull=True)
& Q(assignees__member_project__is_active=True)
& Q(issue_assignee__deleted_at__isnull=True)
& Q(assignees__member_project__project_id=project.id)
),
),
Value([], output_field=ArrayField(UUIDField())),
Expand Down
1 change: 1 addition & 0 deletions apps/api/plane/app/views/issue/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def list(self, request, slug, project_id, issue_id):
~Q(assignees__id__isnull=True)
& Q(assignees__member_project__is_active=True)
& Q(issue_assignee__deleted_at__isnull=True)
& Q(assignees__member_project__project_id=project_id)
),
),
Value([], output_field=ArrayField(UUIDField())),
Expand Down
1 change: 1 addition & 0 deletions apps/api/plane/app/views/issue/sub_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def get(self, request, slug, project_id, issue_id):
~Q(assignees__id__isnull=True)
& Q(assignees__member_project__is_active=True)
& Q(issue_assignee__deleted_at__isnull=True)
& Q(assignees__member_project__project_id=project_id)
),
),
Value([], output_field=ArrayField(UUIDField())),
Expand Down
13 changes: 13 additions & 0 deletions apps/api/plane/app/views/project/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,26 @@ def retrieve(self, request, slug, pk):
)
.filter(archived_at__isnull=True)
.filter(pk=pk)
.prefetch_related("project_projectmember")
).first()

if project is None:
return Response(
{"error": "Project does not exist"}, status=status.HTTP_404_NOT_FOUND
)

project_member_ids = ProjectMember.objects.filter(
project_id=pk, is_active=True
).values_list("member_id", flat=True)

members_ids = set(project_member_ids)

if project.project_lead_id not in members_ids:
project.project_lead = None

if project.default_assignee_id not in members_ids:
project.default_assignee = None

recent_visited_task.delay(
slug=slug,
project_id=pk,
Expand Down
9 changes: 7 additions & 2 deletions apps/api/plane/utils/grouper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Django imports
from django.contrib.postgres.aggregates import ArrayAgg
from django.contrib.postgres.fields import ArrayField
from django.db.models import Q, UUIDField, Value, QuerySet
from django.db.models import Q, UUIDField, Value, QuerySet, OuterRef
from django.db.models.functions import Coalesce

# Module imports
Expand All @@ -23,6 +23,8 @@ def issue_queryset_grouper(
group_by: Optional[str],
sub_group_by: Optional[str],
) -> QuerySet[Issue]:
project_id = queryset.values_list("project_id", flat=True).first()

FIELD_MAPPER: Dict[str, str] = {
"label_ids": "labels__id",
"assignee_ids": "assignees__id",
Expand All @@ -42,7 +44,10 @@ def issue_queryset_grouper(
annotations_map: Dict[str, Tuple[str, Q]] = {
"assignee_ids": (
"assignees__id",
~Q(assignees__id__isnull=True) & Q(issue_assignee__deleted_at__isnull=True),
~Q(assignees__id__isnull=True)
& Q(issue_assignee__deleted_at__isnull=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sangeethailango Why is this filter checking different field than the others?

& Q(assignees__member_project__is_active=True)
& Q(assignees__member_project__project_id=project_id),
),
"label_ids": (
"labels__id",
Expand Down