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

#163383182: Users can comment on articles #31

Merged
merged 1 commit into from
Feb 13, 2019

Conversation

pbkabali
Copy link
Contributor

@pbkabali pbkabali commented Feb 11, 2019

What does this PR do?

  • create Comment and Reply models
  • Implement CRUD operations for comments and replies

Description of the task to be completed?

  • Create API endpoint for users to comment on an article.
  • Create API endpoint for users to create, delete and update a comment
  • Create API endpoint for users to reply to a comment.
  • Create API endpoint for users to create, delete and update a reply on a comment
  • It includes unit tests for the functionality

How should this be manually tested?

  • Visit the PR's app in the postman to view all comment or create a new comment for an article.
  • Get all comment for an article
  • Create a comment
  • To retrieve, update or delete a comment Visit the PR's app in the postman to view all articles or create a new article.
  • Update a comment
  • Delete a comment
  • Retrieve a comment.

What are the relevant pivotal tracker stories?

#163383182

@pep8speaks
Copy link

pep8speaks commented Feb 11, 2019

Hello @pbkabali! Thanks for updating the PR.

Line 28:26: E275 missing whitespace after keyword
Line 183:56: W291 trailing whitespace
Line 202:37: E128 continuation line under-indented for visual indent
Line 223:57: W291 trailing whitespace
Line 224:77: W291 trailing whitespace
Line 225:79: W291 trailing whitespace
Line 226:76: W291 trailing whitespace
Line 253:64: W291 trailing whitespace

Line 20:80: E501 line too long (114 > 79 characters)
Line 24:80: E501 line too long (115 > 79 characters)
Line 25:80: E501 line too long (114 > 79 characters)
Line 34:80: E501 line too long (114 > 79 characters)
Line 38:80: E501 line too long (114 > 79 characters)
Line 39:80: E501 line too long (115 > 79 characters)

Line 8:68: W291 trailing whitespace

Line 42:13: E122 continuation line missing indentation or outdented
Line 60:21: E122 continuation line missing indentation or outdented
Line 67:70: W291 trailing whitespace
Line 89:21: E122 continuation line missing indentation or outdented
Line 106:21: E128 continuation line under-indented for visual indent
Line 149:13: E122 continuation line missing indentation or outdented
Line 168:17: E122 continuation line missing indentation or outdented
Line 175:75: W291 trailing whitespace
Line 197:21: E122 continuation line missing indentation or outdented
Line 213:80: E501 line too long (80 > 79 characters)

Line 89:80: E501 line too long (91 > 79 characters)
Line 92:80: E501 line too long (81 > 79 characters)
Line 95:80: E501 line too long (82 > 79 characters)
Line 98:80: E501 line too long (83 > 79 characters)

Comment last updated on February 12, 2019 at 13:28 Hours UTC

@karuhanga karuhanga temporarily deployed to ah-backend-summer-stagin-pr-31 February 11, 2019 11:50 Inactive
Copy link
Contributor

@fahdjamy fahdjamy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please Install and follow pep8 standards @pbkabali.

'ordering': ['created_at'],
},
),
migrations.CreateModel(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your PR seems to have updated one of the previous migration files and this could break the code in staging and production. If you could please move the added migrations for comments to a new migration file that would be amazing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@missvicki I did not touch any existing models. These are new models for comments and replies and should not affect any existing setup.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@missvicki, please clarify on this. I seem to agree with @pbkabali on this one.

@pbkabali pbkabali force-pushed the ft-comment-on-article-163383182 branch from 7f97c89 to 18c6a9e Compare February 11, 2019 21:54
@karuhanga karuhanga temporarily deployed to ah-backend-summer-stagin-pr-31 February 11, 2019 21:55 Inactive
@pbkabali pbkabali changed the title feat:users can comment on articles #163383182: Users can comment on articles Feb 11, 2019
def get(self, request, slug):
"""Retrieve all comments on an article"""
self.get_required_objects(request, slug)
comments = Comment.objects.filter(article=self.article)
Copy link
Collaborator

@karuhanga karuhanga Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you think it would make sense to sort the comments by timestamp, given we shall be displaying them based on that order?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right @karuhanga . The ordering on the serializer depends on the created_at field

data=self.data
)
serializer.is_valid(raise_exception=True)
serializer.save(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thumbs up on using the serializer properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

data=self.data
)
serializer.is_valid(raise_exception=True)
serializer.save(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thumbs up on using the serializer pattern the right way.

Copy link
Collaborator

@karuhanga karuhanga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good work on this @pbkabali, especially on using the serializer pattern correctly, including the save.
I have put specific concerns in the comments, and would also suggest you look into drastically reducing the pep8 violations.

'reply') if 'reply' in request.data else request.data

def get_author_profile(self, request):
self.requester = Profile.objects.get(user=request.user)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pbkabali I think you should use either a get_object_or_404 or a try and except just incase a Profile does not exist a get might throw an error if that profile does not exist

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oma0256 I get your point because the get endpoints do not need authentication. But also this function is not called on any get endpoint. So I think it should be fine

@malep2007
Copy link
Contributor

@pbkabali there are still PEP8 issues. Please rectify those ASAP and get back to me

@malep2007
Copy link
Contributor

Please Install and follow pep8 standards @pbkabali.

Was this done, @pbkabali?

@pbkabali pbkabali force-pushed the ft-comment-on-article-163383182 branch from 18c6a9e to c0fb489 Compare February 12, 2019 11:41
@karuhanga karuhanga temporarily deployed to ah-backend-summer-stagin-pr-31 February 12, 2019 11:41 Inactive
Copy link
Contributor

@fahdjamy fahdjamy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing the requested changes.

-implement CRUD operations for comments on articles and replies to
comments

[Starts: #163383182]
@pbkabali pbkabali force-pushed the ft-comment-on-article-163383182 branch from a88a357 to 216bf0a Compare February 12, 2019 13:28
@malep2007 malep2007 merged commit 3f2347e into develop Feb 13, 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.

None yet

8 participants