-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
authors/apps/ratings/views.py
Outdated
|
||
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) |
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.
line too long (84 > 79 characters)
authors/apps/ratings/views.py
Outdated
# 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) | ||
|
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.
blank line contains whitespace
authors/apps/ratings/views.py
Outdated
@@ -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) |
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.
line too long (96 > 79 characters)
[Finishes #163459553]
4f9df8a
to
7ba9595
Compare
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: