-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WEB-2937] feat: home recent activies list endpoint (#6295)
* Crud for wuick links * Validate quick link existence * Add custom method for destroy and retrieve * Add List method * Remove print statements * List all the workspace quick links * feat: endpoint to get recently active items * Resolve conflicts * Resolve conflicts * Add filter to only list required entities * Return required fields * Add filter * Add filter
- Loading branch information
1 parent
4652ad0
commit 870ca17
Showing
6 changed files
with
141 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Third party imports | ||
from rest_framework import status | ||
from rest_framework.response import Response | ||
|
||
from plane.db.models import UserRecentVisit | ||
from plane.app.serializers import WorkspaceRecentVisitSerializer | ||
|
||
# Modules imports | ||
from ..base import BaseViewSet | ||
from plane.app.permissions import allow_permission, ROLE | ||
|
||
class UserRecentVisitViewSet(BaseViewSet): | ||
model = UserRecentVisit | ||
|
||
def get_serializer_class(self): | ||
return WorkspaceRecentVisitSerializer | ||
|
||
@allow_permission([ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST], level="WORKSPACE") | ||
def list(self, request, slug): | ||
user_recent_visits = UserRecentVisit.objects.filter(workspace__slug=slug) | ||
|
||
entity_name = request.query_params.get("entity_name") | ||
|
||
if entity_name: | ||
user_recent_visits = user_recent_visits.filter(entity_name=entity_name) | ||
|
||
user_recent_visits = user_recent_visits.filter(entity_name__in=["issue","page","project"]) | ||
|
||
serializer = WorkspaceRecentVisitSerializer(user_recent_visits[:20], many=True) | ||
return Response(serializer.data, status=status.HTTP_200_OK) | ||
|