forked from mirrors/bookwyrm
Lift book lookup from create_review to review action.
This commit is contained in:
parent
d43c513d19
commit
4e67d8bb38
2 changed files with 6 additions and 5 deletions
|
@ -23,11 +23,8 @@ def create_review_from_activity(author, activity):
|
||||||
return review
|
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 '''
|
''' 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)
|
content = sanitize(content)
|
||||||
|
|
||||||
# no ratings outside of 0-5
|
# no ratings outside of 0-5
|
||||||
|
|
|
@ -11,6 +11,7 @@ from fedireads import forms, models, books_manager, outgoing
|
||||||
from fedireads.goodreads_import import GoodreadsCsv
|
from fedireads.goodreads_import import GoodreadsCsv
|
||||||
from fedireads.settings import DOMAIN
|
from fedireads.settings import DOMAIN
|
||||||
from fedireads.views import get_user_from_username
|
from fedireads.views import get_user_from_username
|
||||||
|
from fedireads.books_manager import get_or_create_book
|
||||||
|
|
||||||
|
|
||||||
def user_login(request):
|
def user_login(request):
|
||||||
|
@ -172,7 +173,10 @@ def review(request):
|
||||||
content = form.data.get('content')
|
content = form.data.get('content')
|
||||||
rating = form.data.get('rating')
|
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)
|
return redirect('/book/%s' % book_identifier)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue