-
Notifications
You must be signed in to change notification settings - Fork 8
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
#164069241 like a comment #36
Conversation
authors/apps/comments/views.py
Outdated
@@ -0,0 +1,161 @@ | |||
from django.shortcuts import get_object_or_404 | |||
from rest_framework.response import Response | |||
from rest_framework.serializers import ValidationError |
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.
Thanks for the good work @wasibani-roy, however ValidationError and status are unused, you can consider refactoring to have clean code.
authors/apps/comments/models.py
Outdated
@@ -0,0 +1,24 @@ | |||
from django.conf import settings |
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.
Thanks for the good work @wasibani-roy, however Settings is unused, you can consider refactoring to have clean code.
authors/apps/comments/views.py
Outdated
try: | ||
user = get_object_or_404( | ||
Profile, user=self.request.user) | ||
comment = get_object_or_404(Comment, pk=kwargs.get("pk")) |
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.
Thanks for the good work @wasibani-roy, however, I feel like this line is not needed as you don't seem to use it. please clarify if you use it somewhere in the implementation. If you don't use it, we can remove it to improve the performance of the database.
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.
This try is there to handle situations where the user may try to unlike a comment they had not originally like you see such if not handled would cause the application to crash. That's why we have the try-catch block there
0366201
to
c705886
Compare
3fd1448
532b04b
to
3fd1448
Compare
cc8bf8f
cc8bf8f
to
8dada9d
Compare
- Ensure that authenticated users can like a comment on an article - Ensure that a user can view all likes on a comment - Ensure that a user can unlike a comment on an article [Starts #164069241]
875aa2b
8dada9d
to
875aa2b
Compare
Code Climate has analyzed commit 875aa2b and detected 0 issues on this pull request. 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.
Thank you for the goodwork @wasibani-roy
What does this PR do?
This PR enables the user of a system to like a comment on an article they find interesting
Description of Task to be completed?
How should this be manually tested
Clone the repo and cd into Ah-backend-aquaman
git checkout ft-like-comment-164069241
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py runserver
Register and then login into the system
The below endpoint will be used to favorite an article
Like a comment
PUT http://127.0.0.1:8000/api/articleslug/comments/commentID/like/
View likes on a comment
GET http://127.0.0.1:8000/api/articleslug/comments/commentID/like/
Unlike a comment
DELETE http://127.0.0.1:8000/api/articleslug/comments/commentID/like/
Any background context you want to provide?
N/A
What are the relevant pivotal tracker stories?
Screenshots
like a comment
Getting likes on a comment
Unliking a comment