From b11852f14f7aedf5889c2ffc849999696f0af69d Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Wed, 13 Dec 2023 12:58:41 +0530 Subject: [PATCH] chore: project views id mapped --- apiserver/plane/app/serializers/view.py | 4 ++-- apiserver/plane/app/views/view.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apiserver/plane/app/serializers/view.py b/apiserver/plane/app/serializers/view.py index e7502609a..70c355457 100644 --- a/apiserver/plane/app/serializers/view.py +++ b/apiserver/plane/app/serializers/view.py @@ -2,7 +2,7 @@ from rest_framework import serializers # Module imports -from .base import BaseSerializer +from .base import BaseSerializer, DynamicBaseSerializer from .workspace import WorkspaceLiteSerializer from .project import ProjectLiteSerializer from plane.db.models import GlobalView, IssueView, IssueViewFavorite @@ -38,7 +38,7 @@ class GlobalViewSerializer(BaseSerializer): return super().update(instance, validated_data) -class IssueViewSerializer(BaseSerializer): +class IssueViewSerializer(DynamicBaseSerializer): is_favorite = serializers.BooleanField(read_only=True) project_detail = ProjectLiteSerializer(source="project", read_only=True) workspace_detail = WorkspaceLiteSerializer(source="workspace", read_only=True) diff --git a/apiserver/plane/app/views/view.py b/apiserver/plane/app/views/view.py index eb76407b7..80809c2ad 100644 --- a/apiserver/plane/app/views/view.py +++ b/apiserver/plane/app/views/view.py @@ -181,10 +181,7 @@ class GlobalViewIssuesViewSet(BaseViewSet): issues = IssueLiteSerializer(issue_queryset, many=True, fields=fields if fields else None).data issue_dict = {str(issue["id"]): issue for issue in issues} - return Response( - issue_dict, - status=status.HTTP_200_OK, - ) + return Response(issue_dict, status=status.HTTP_200_OK) class IssueViewViewSet(BaseViewSet): @@ -216,6 +213,13 @@ class IssueViewViewSet(BaseViewSet): .order_by("-is_favorite", "name") .distinct() ) + + def list(self, request, slug, project_id): + queryset = self.get_queryset() + fields = [field for field in request.GET.get("fields", "").split(",") if field] + views = IssueViewSerializer(queryset, many=True, fields=fields if fields else None).data + views_dict = {str(view["id"]): view for view in views} + return Response(views_dict, status=status.HTTP_200_OK) class IssueViewFavoriteViewSet(BaseViewSet):