-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#161966615 like and dislike articles #25
Conversation
return Response({'message':"article not found."}) | ||
|
||
|
||
class LikeArticle(UpdateAPIView): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
return Response(message, status.HTTP_200_OK) | ||
|
||
|
||
class DislikeArticle(UpdateAPIView): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
body = serializers.CharField() | ||
author = UserSerializer(read_only = True) | ||
|
||
def likes(self, instance): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
liked = instance.likes.all().filter(id=user_id).count() == 1 | ||
return {'likes': instance.likes.count(), 'User': liked} | ||
|
||
def dislikes(self, instance): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
0b6ee09
to
d6c0e4b
Compare
cdfdca6
to
fb8c508
Compare
user = request.user | ||
# checks for the boolean value of liking an article | ||
liked = bool(user in article.like.all()) | ||
if liked is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
user = request.user | ||
# checks for the boolean value of disliking an article | ||
disliked = bool(user in article.dislike.all()) | ||
if disliked is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
b901d6a
to
80747b0
Compare
…sliking an article - add tests for liking and disliking fuctionality - modify the base file to accomodate the tests - add fields in the model for liking and disliking an article - add a method in the serializer for returning a liked or disliked functionality - add views for liking and disliking an article. [Delivers #161966615]
80747b0
to
e4dcd39
Compare
Code Climate has analyzed commit e4dcd39 and detected 4 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What does this pull request do?
This PR implements the functionality of liking and disliking articles.
Description of the tasks to be completed?
PUT /api/slug/like/
PUT /api/slug/dislike/
How should this be manually tested?
testing:
Screenshots:
Like an article
Unlike an article
Disliked an article
Un-dislike an article
What are the relevant Pivotal Tracker Stories
#161966615
Checklist: