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

#161966613 Comments #22

Merged
merged 3 commits into from
Dec 13, 2018
Merged

#161966613 Comments #22

merged 3 commits into from
Dec 13, 2018

Conversation

verenceLola
Copy link
Contributor

What does this pull request do?

This PR implements the CRUD methods for comments and comment replies.

Description of the tasks to be completed?

  • create article's comment
    POST /api/articles/:slug/comments

  • get article's comments
    GET /api/articles/:slug/comments

  • update article's comment
    PUT /api/articles/:slug/comments/:id

  • delete article's comment
    DELETE /api/articles/:slug/comments/:id

  • test the above functionalities

How should this be manually tested?

  • clone the repo git clone https://github.com/andela/ah-technocrats.git
  • change to the cloned directory cd ah-technocrats
  • git checkout ft-comments-161966613
  • make and activate virtual environment python3 -m venv venv and then source venv/bin/activate
  • install dependencies pip install -r requirements.txt
  • make Django migrations python manage.py makemigrations
  • migrate python manage.py migrate
  • finally run the server on port 8000 python manage.py runserver

testing automatically:

  • run python manage.py test to run automatic tests

testing manually:

  • the functionalities can also be manually tested using Postman on the above endpoints.

Screenshots:

Commenting on an article

screenshot 2018-12-12 at 19 49 20

Get comments for an article

screenshot 2018-12-12 at 19 47 28

Update an article's comment

screenshot 2018-12-12 at 19 51 32

Delete article's comment

screenshot 2018-12-12 at 19 52 37

Reply to a comment:

screenshot 2018-12-12 at 19 55 36

Get comment's replies:

screenshot 2018-12-12 at 19 54 33

Edit a comment's reply:

image

Delete a comment's reply:

image

Testsing

image

What are the relevant Pivotal Tracker Stories

#161966613

Checklist:

  • My code follows the style guidelines of this project
  • At least 2 people have reviewed my PR
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • My PR has one commit.

@verenceLola verenceLola added the Merge after #21 Merge after PR no #21 label Dec 12, 2018
@SilasKenneth SilasKenneth changed the base branch from ft-create-article-161966610 to develop December 13, 2018 07:11
"""
delete comment with comment_id of article with specified slug
"""
try:
Copy link

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.

update comment with comment_id or artcle_slug
"""
reply_data = request.data.get('reply', {})
try:
Copy link

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.

"""
delete comment with comment_id of article with specified slug
"""
try:
Copy link

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.

update comment with comment_id or artcle_slug
"""
comment_data = request.data.get('comment', {})
try:
Copy link

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.

**validated_data
)

Copy link

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.

vincent Onyango added 3 commits December 13, 2018 13:48
 - Add functionality to allow commenting articles
 - Add functionality to allow replying to an article comment(allow threading comments)

[Delivers #161966613]
 - write tests for commenting articles

[Delivers #161966613]
…ality

- write test for testing replying to comments of articles

[Delivers #161966613]
**validated_data
)

Copy link

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.

model = Reply
exclude = ('comment',)

Copy link

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.

'replies'
)

Copy link

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.

comments = self.queryset.filter(**filters)
serializer = CommentSerializer(comments, many=True)
data = serializer.data
return Response({
Copy link

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.

replies = self.queryset.filter(comment__id=comment_pk)
serializer = ReplySerializer(replies, many=True)
data = serializer.data
return Response({
Copy link

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.

@codeclimate
Copy link

codeclimate bot commented Dec 13, 2018

Code Climate has analyzed commit 43ddabd and detected 11 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1
Duplication 10

View more on Code Climate.

Copy link

@Mnickii Mnickii left a comment

Choose a reason for hiding this comment

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

LGTM

@Mnickii Mnickii merged commit d1819f9 into develop Dec 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merge after #21 Merge after PR no #21
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants