Skip to content

Commit

Permalink
이미지 좋아요한 사람 출력
Browse files Browse the repository at this point in the history
  • Loading branch information
shing100 committed Aug 23, 2018
1 parent b724828 commit be66e80
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,4 @@ urlpatterns = [
> field-lookups
- https://docs.djangoproject.com/en/1.11/topics/db/queries/#field-lookups
- https://docs.djangoproject.com/en/1.11/ref/models/querysets/#values
4 changes: 2 additions & 2 deletions limstagram/images/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
urlpatterns = [
path("", view=views.Feed.as_view(), name="feed"),
path("<int:image_id>", view=views.ImageDetail.as_view(), name="feed"),
path("<int:image_id>/like/", view=views.LikeImage.as_view(), name="like_image"),
path("<int:image_id>/unlike/", view=views.unLikeImage.as_view(), name="unlike_image"),
path("<int:image_id>/likes/", view=views.LikeImage.as_view(), name="like_image"),
path("<int:image_id>/unlikes/", view=views.unLikeImage.as_view(), name="unlike_image"),
path("<int:image_id>/comments", view=views.CommentOnImage.as_view(), name="commnet_image"),
path("<int:image_id>/comments/<int:comment_id>", view=views.ModerateComments.as_view(), name="commnet_image"),
path("comments/<int:comment_id>", view=views.Comment.as_view(), name="comment"),
Expand Down
16 changes: 16 additions & 0 deletions limstagram/images/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from rest_framework.response import Response
from rest_framework import status
from . import models, serializers
from limstagram.users import models as user_models
from limstagram.users import serializers as user_serializers
from limstagram.notifications import views as notification_views

class Feed(APIView):
Expand Down Expand Up @@ -36,6 +38,20 @@ def get(self, request, format=None):

class LikeImage(APIView):

def get(self, request, image_id, format=None):
likes = models.Like.objects.filter(image__id=image_id)

# print(likes.values())
# print(likes.values('creator_id'))
## arrat 안에 있는 user id 를 찾기

like_creators_ids = likes.values('creator_id')
users = user_models.User.objects.filter(id__in=like_creators_ids)

serializer = user_serializers.ListUserSerializer(users, many=True)

return Response(serializer.data, status=status.HTTP_200_OK)

def post(self, request, image_id, format=None):

# notification
Expand Down

0 comments on commit be66e80

Please sign in to comment.