Lift book lookup from create_review to review action.

This commit is contained in:
Adam Kelly 2020-04-01 15:10:59 +01:00
parent d43c513d19
commit 4e67d8bb38
2 changed files with 6 additions and 5 deletions

View file

@ -23,11 +23,8 @@ def create_review_from_activity(author, activity):
return review
def create_review(user, possible_book, name, content, rating):
def create_review(user, book, name, content, rating):
''' a book review has been added '''
# throws a value error if the book is not found
book = get_or_create_book(possible_book)
content = sanitize(content)
# no ratings outside of 0-5

View file

@ -11,6 +11,7 @@ from fedireads import forms, models, books_manager, outgoing
from fedireads.goodreads_import import GoodreadsCsv
from fedireads.settings import DOMAIN
from fedireads.views import get_user_from_username
from fedireads.books_manager import get_or_create_book
def user_login(request):
@ -172,7 +173,10 @@ def review(request):
content = form.data.get('content')
rating = form.data.get('rating')
outgoing.handle_review(request.user, book_identifier, name, content, rating)
# throws a value error if the book is not found
book = get_or_create_book(book_identifier)
outgoing.handle_review(request.user, book, name, content, rating)
return redirect('/book/%s' % book_identifier)