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

#163459553 Fix post rating #44

Merged
merged 1 commit into from
Jan 25, 2019
Merged

Conversation

gwako94
Copy link
Contributor

@gwako94 gwako94 commented Jan 24, 2019

What does this PR do?

Fix user can rate multiple articles

Description of Task to be completed?

Have user rating multiple articles

How should this be manually tested?

Test as described in this PR

Any background context you want to provide?

What are the relevant pivotal tracker stories?

#163459553

Screenshots (if appropriate)

Questions:

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.


serializer.is_valid(raise_exception=True)
serializer.save()

rating = Rating.objects.get(rater_id=request.user.id)
rating = Rating.objects.get(rater_id=request.user.id, article_id=article.id)

Choose a reason for hiding this comment

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

line too long (84 > 79 characters)

# perform an update if exists
serializer = BasicRatingSerializer(
current_rating, data=request.data, partial=True)

except Rating.DoesNotExist:
# create a new rating if does not exists
serializer = BasicRatingSerializer(data=rating_data)

Choose a reason for hiding this comment

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

blank line contains whitespace

@@ -41,19 +40,20 @@ def post(self, request, slug):

# check if rating exists for the article
try:
current_rating = Rating.objects.get(rater_id=request.user.id)
current_rating = Rating.objects.get(rater_id=request.user.id, article_id=article.id)

Choose a reason for hiding this comment

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

line too long (96 > 79 characters)

[Finishes #163459553]
@gwako94 gwako94 force-pushed the fix-post-article-rating-163459553 branch from 4f9df8a to 7ba9595 Compare January 24, 2019 17:02
@brayovsky brayovsky merged commit cb8bff2 into develop Jan 25, 2019
@brayovsky brayovsky deleted the fix-post-article-rating-163459553 branch January 25, 2019 06:54
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

3 participants