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

#161966611: Users should rate articles #23

Merged
merged 1 commit into from
Dec 13, 2018

Conversation

SilasKenneth
Copy link
Contributor

What does this PR do?

The user should be able to rate articles and also see ratings for all the articles in the authorshaven API.

Description of Task to be completed?

The user should be able to rate articles on the authorshaven api. The users should then be able to see the ratings depicted on the articles page when they request for it. The user, in this case an API user authenticated or not should be able to view all ratings of articles.
To rate an article the user must be authenticated first.

How should this be manually tested?

To test the application follow the steps below.

  • Clone the repo using git clone https://github.com/andela/ah-technocrats.git
  • cd ah-technocrats
  • git checkout ft-user-rate-articles-161966611 to switch to current branch
  • run virtualenv env -p python3 to create a virtual environment for the application
  • Activate the environment source env/bin/activate
  • Install required modules using pip install -r requirements.txt
  • run python manage.py test to test

Any background context you want to provide?

  • The project requires that you have python version 3 installed. For the Django version the project has just been tested with Django 2.1 which is the latest version as of this PR.

What are the relevant pivotal tracker stories?

#161966611

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.

Screenshots

How ratings of articles appear when you view multiple articles

screenshot 2018-12-12 18 55 35

The screen you get when you rate an article

screenshot 2018-12-12 18 56 18

The ratings when viewing a single article have distributions

That is, if ten users rate the article 5 then the distribution will be
{'5': '1'}
screenshot 2018-12-12 20 57 12

except Exception as ex:
response = dict(errors={"message": "There was a problem sending the rating"
" try again later."})
return Response(response, status=status.HTTP_503_SERVICE_UNAVAILABLE)
Copy link

Choose a reason for hiding this comment

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

Avoid too many return statements within this function.

authors/apps/articles/views.py Outdated Show resolved Hide resolved
authors/apps/articles/views.py Outdated Show resolved Hide resolved
authors/apps/articles/models.py Outdated Show resolved Hide resolved
@SilasKenneth SilasKenneth force-pushed the ft-user-rate-articles-161966611 branch 12 times, most recently from 53c462f to 6cca04f Compare December 13, 2018 16:33
- This delivers code to allow users rate articles in the api

[Delivers #161966611]
@codeclimate
Copy link

codeclimate bot commented Dec 13, 2018

Code Climate has analyzed commit 7f5a82d and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2

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 8440f43 into develop Dec 13, 2018
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.

2 participants