Adds ratings
This commit is contained in:
parent
f7cb3d9444
commit
a27effd05d
15 changed files with 170 additions and 19 deletions
|
@ -25,6 +25,17 @@ def create_review_from_activity(author, activity):
|
|||
return review
|
||||
|
||||
|
||||
def create_rating(user, book, rating):
|
||||
''' a review that's just a rating '''
|
||||
if not rating or rating < 1 or rating > 5:
|
||||
raise ValueError('Invalid rating')
|
||||
return models.Review.objects.create(
|
||||
user=user,
|
||||
book=book,
|
||||
rating=rating,
|
||||
)
|
||||
|
||||
|
||||
def create_review(user, book, name, content, rating):
|
||||
''' a book review has been added '''
|
||||
name = sanitize(name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue