-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
Hello @pbkabali! Thanks for updating the PR.
Comment last updated on February 12, 2019 at 13:28 Hours UTC |
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.
Please Install and follow pep8 standards @pbkabali.
'ordering': ['created_at'], | ||
}, | ||
), | ||
migrations.CreateModel( |
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.
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.
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.
@missvicki I did not touch any existing models. These are new models for comments and replies and should not affect any existing setup.
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.
@missvicki, please clarify on this. I seem to agree with @pbkabali on this one.
7f97c89
to
18c6a9e
Compare
def get(self, request, slug): | ||
"""Retrieve all comments on an article""" | ||
self.get_required_objects(request, slug) | ||
comments = Comment.objects.filter(article=self.article) |
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.
Don't you think it would make sense to sort the comments by timestamp
, given we shall be displaying them based on that order?
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.
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( |
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.
Thumbs up on using the serializer
properly.
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
data=self.data | ||
) | ||
serializer.is_valid(raise_exception=True) | ||
serializer.save( |
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.
Thumbs up on using the serializer
pattern the right way.
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.
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) |
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.
@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
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.
@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
@pbkabali there are still PEP8 issues. Please rectify those ASAP and get back to me |
18c6a9e
to
c0fb489
Compare
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 implementing the requested changes.
c0fb489
to
a88a357
Compare
-implement CRUD operations for comments on articles and replies to comments [Starts: #163383182]
a88a357
to
216bf0a
Compare
What does this PR do?
Description of the task to be completed?
How should this be manually tested?
What are the relevant pivotal tracker stories?
#163383182