Skip to content

Commit

Permalink
이미지 상세보기
Browse files Browse the repository at this point in the history
  • Loading branch information
shing100 committed Aug 22, 2018
1 parent 5cfdb46 commit b724828
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions limstagram/images/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Meta:
'comments',
'like_count',
'creator',
'created_at',
'tags'
)

1 change: 1 addition & 0 deletions limstagram/images/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
app_name = "images"
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>/comments", view=views.CommentOnImage.as_view(), name="commnet_image"),
Expand Down
16 changes: 15 additions & 1 deletion limstagram/images/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get(self, request, format=None):
for image in user_images:
image_list.append(image)

my_images = user.image.all()[:2]
my_images = user.images.all()[:2]

for image in my_images:
image_list.append(image)
Expand Down Expand Up @@ -156,3 +156,17 @@ def delete(self, request, image_id, comment_id, format=None):
return Response(status=status.HTTP_404_NOT_FOUND)

return Response(status=status.HTTP_204_NO_CONTENT)


class ImageDetail(APIView):

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

try:
image = models.Image.objects.get(id=image_id)
except models.Image.DoesNotExist:
return Response(status=status.HTTP_404_NOT_FOUND)

serializer = serializers.ImageSerializer(image)

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

0 comments on commit b724828

Please sign in to comment.