-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(requests): Add requests list API
- Loading branch information
1 parent
c8c4eab
commit d078e53
Showing
3 changed files
with
23 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from app.models import FriendDecision | ||
from rest_framework import viewsets, permissions | ||
from app.models.user_profile import UserProfile | ||
from app.serializers.user_profile import UserProfileSerializer | ||
|
||
class FriendRequestViewSet(viewsets.ModelViewSet): | ||
queryset = UserProfile.objects.all() | ||
serializer_class = UserProfileSerializer | ||
permission_classes = ( | ||
permissions.IsAuthenticated, | ||
) | ||
|
||
def filter_queryset(self, queryset): | ||
received_friend = FriendDecision.objects.filter(receiver_id=self.request.user.id).values_list('sender_id', flat=True) | ||
queryset = queryset.filter(user_id__in=received_friend).exclude(user_id=self.request.user.id) | ||
return queryset |