From a829e6fc40b2e0fd228f8077ddb3b2ac866df113 Mon Sep 17 00:00:00 2001 From: Bavisetti Narayan <72156168+NarayanBavisetti@users.noreply.github.com> Date: Thu, 13 Jul 2023 16:51:42 +0530 Subject: [PATCH] chore: added is_favorite filter (#1518) * fix: notification filtering * dev: reverse logic for archive filtering * dev: fix watching notification * dev: read filter * dev: update automatic issue archival and close to send notifications * dev: update archival structure for auto close issues * chore: added is_favorite filter * fix: removed the unwanted filter --------- Co-authored-by: pablohashescobar --- apiserver/plane/api/urls.py | 1 - apiserver/plane/api/views/project.py | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apiserver/plane/api/urls.py b/apiserver/plane/api/urls.py index 55b14baa8..dc5b0e1dc 100644 --- a/apiserver/plane/api/urls.py +++ b/apiserver/plane/api/urls.py @@ -478,7 +478,6 @@ urlpatterns = [ "workspaces//user-favorite-projects/", ProjectFavoritesViewSet.as_view( { - "get": "list", "post": "create", } ), diff --git a/apiserver/plane/api/views/project.py b/apiserver/plane/api/views/project.py index 822dc78b5..357f94e10 100644 --- a/apiserver/plane/api/views/project.py +++ b/apiserver/plane/api/views/project.py @@ -96,6 +96,7 @@ class ProjectViewSet(BaseViewSet): def list(self, request, slug): try: + is_favorite = request.GET.get("is_favorite", "all") subquery = ProjectFavorite.objects.filter( user=self.request.user, project_id=OuterRef("pk"), @@ -126,6 +127,12 @@ class ProjectViewSet(BaseViewSet): .values("count") ) ) + + if is_favorite == "true": + projects = projects.filter(is_favorite=True) + if is_favorite == "false": + projects = projects.filter(is_favorite=False) + return Response(ProjectDetailSerializer(projects, many=True).data) except Exception as e: capture_exception(e)