Skip to content
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

Merged
merged 1 commit into from
Mar 21, 2019
Merged

Conversation

wasibani-roy
Copy link
Contributor

@wasibani-roy wasibani-roy commented Mar 19, 2019

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?

  • Enable the user to like a comment
  • Enable a user view likes on a comment
  • Enable user unlike on a comment

How should this be manually tested

Any background context you want to provide?
N/A

What are the relevant pivotal tracker stories?

Screenshots

like a comment
Screenshot 2019-03-21 at 09 12 22

Getting likes on a comment
Screenshot 2019-03-21 at 09 12 46

Unliking a comment
Screenshot 2019-03-21 at 09 13 04

@@ -0,0 +1,161 @@
from django.shortcuts import get_object_or_404
from rest_framework.response import Response
from rest_framework.serializers import ValidationError
Copy link
Contributor

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.

@@ -0,0 +1,24 @@
from django.conf import settings
Copy link
Contributor

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.

try:
user = get_object_or_404(
Profile, user=self.request.user)
comment = get_object_or_404(Comment, pk=kwargs.get("pk"))
Copy link
Contributor

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.

Copy link
Contributor Author

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

@wasibani-roy wasibani-roy force-pushed the ft-like-comment-164069241 branch 10 times, most recently from 0366201 to c705886 Compare March 21, 2019 08:05
CryceTruly
CryceTruly previously approved these changes Mar 21, 2019
Peace-Apple
Peace-Apple previously approved these changes Mar 21, 2019
BagzieGracious
BagzieGracious previously approved these changes Mar 21, 2019
CryceTruly
CryceTruly previously approved these changes Mar 21, 2019
Peace-Apple
Peace-Apple previously approved these changes Mar 21, 2019
@wasibani-roy wasibani-roy force-pushed the ft-like-comment-164069241 branch 2 times, most recently from cc8bf8f to 8dada9d Compare March 21, 2019 09:54
BagzieGracious
BagzieGracious previously approved these changes Mar 21, 2019
CryceTruly
CryceTruly previously approved these changes Mar 21, 2019
Peace-Apple
Peace-Apple previously approved these changes Mar 21, 2019
- 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]
@codeclimate
Copy link

codeclimate bot commented Mar 21, 2019

Code Climate has analyzed commit 875aa2b and detected 0 issues on this pull request.

View more on Code Climate.

Copy link
Contributor

@BagzieGracious BagzieGracious left a 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

@marthamareal marthamareal merged commit 140135b into develop Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants