Parse rating int in view handler.

Activity already represents rating as an int in the json.
This commit is contained in:
Adam Kelly
2020-04-02 10:25:47 +01:00
parent cceb433620
commit 5bcf65a8a1
2 changed files with 3 additions and 4 deletions

View File

@ -30,10 +30,9 @@ def create_review(user, book, name, content, rating):
content = sanitize(content)
# no ratings outside of 0-5
try:
rating = int(rating)
if rating:
rating = rating if 1 <= rating <= 5 else None
except ValueError:
else:
rating = None
return models.Review.objects.create(