Adds more urls
This commit is contained in:
31
fedireads/activity.py
Normal file
31
fedireads/activity.py
Normal file
@@ -0,0 +1,31 @@
|
||||
''' Handle user activity '''
|
||||
from fedireads import models
|
||||
from fedireads.openlibrary import get_or_create_book
|
||||
from fedireads.sanitize_html import InputHtmlParser
|
||||
|
||||
|
||||
def create_review(user, possible_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)
|
||||
|
||||
# sanitize review html
|
||||
import pdb;pdb.set_trace()
|
||||
parser = InputHtmlParser()
|
||||
parser.feed(content)
|
||||
content = parser.get_output()
|
||||
|
||||
# no ratings outside of 0-5
|
||||
rating = rating if 0 <= rating <= 5 else 0
|
||||
|
||||
review = models.Review.objects.create(
|
||||
user=user,
|
||||
book=book,
|
||||
name=name,
|
||||
rating=rating,
|
||||
content=content,
|
||||
)
|
||||
|
||||
return review
|
||||
|
||||
|
||||
Reference in New Issue
Block a user