forked from github/plane
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 <nikhilschacko@gmail.com>
This commit is contained in:
parent
864e592bc5
commit
a829e6fc40
@ -478,7 +478,6 @@ urlpatterns = [
|
|||||||
"workspaces/<str:slug>/user-favorite-projects/",
|
"workspaces/<str:slug>/user-favorite-projects/",
|
||||||
ProjectFavoritesViewSet.as_view(
|
ProjectFavoritesViewSet.as_view(
|
||||||
{
|
{
|
||||||
"get": "list",
|
|
||||||
"post": "create",
|
"post": "create",
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
@ -96,6 +96,7 @@ class ProjectViewSet(BaseViewSet):
|
|||||||
|
|
||||||
def list(self, request, slug):
|
def list(self, request, slug):
|
||||||
try:
|
try:
|
||||||
|
is_favorite = request.GET.get("is_favorite", "all")
|
||||||
subquery = ProjectFavorite.objects.filter(
|
subquery = ProjectFavorite.objects.filter(
|
||||||
user=self.request.user,
|
user=self.request.user,
|
||||||
project_id=OuterRef("pk"),
|
project_id=OuterRef("pk"),
|
||||||
@ -126,6 +127,12 @@ class ProjectViewSet(BaseViewSet):
|
|||||||
.values("count")
|
.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)
|
return Response(ProjectDetailSerializer(projects, many=True).data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
capture_exception(e)
|
capture_exception(e)
|
||||||
|
Loading…
Reference in New Issue
Block a user