diff --git a/fedireads/status.py b/fedireads/status.py index 7d6f6b66..61832dd9 100644 --- a/fedireads/status.py +++ b/fedireads/status.py @@ -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( diff --git a/fedireads/view_actions.py b/fedireads/view_actions.py index d1542512..34d4f411 100644 --- a/fedireads/view_actions.py +++ b/fedireads/view_actions.py @@ -172,7 +172,7 @@ def review(request): # TODO: validation, htmlification name = form.data.get('name') content = form.data.get('content') - rating = form.data.get('rating') + rating = form.cleaned_data.get('rating') # throws a value error if the book is not found book = get_or_create_book(book_identifier)