Adds ReviewRating model
I can't just calling Rating because that would clash with the rating field
This commit is contained in:
@ -8,7 +8,8 @@ from .connector import Connector
|
||||
|
||||
from .shelf import Shelf, ShelfBook
|
||||
|
||||
from .status import Status, GeneratedNote, Review, Comment, Quotation
|
||||
from .status import Status, GeneratedNote, Comment, Quotation
|
||||
from .status import Review, ReviewRating
|
||||
from .status import Boost
|
||||
from .attachment import Image
|
||||
from .favorite import Favorite
|
||||
|
@ -222,6 +222,22 @@ class Review(Status):
|
||||
pure_type = 'Article'
|
||||
|
||||
|
||||
class ReviewRating(Review):
|
||||
''' a subtype of review that only contains a rating '''
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.rating:
|
||||
raise ValueError('Rating object must include a numerical rating')
|
||||
return super().save(*args, **kwargs)
|
||||
|
||||
@property
|
||||
def pure_content(self):
|
||||
#pylint: disable=bad-string-format-type
|
||||
return 'Rated "%s": %d' % (self.book.title, self.rating)
|
||||
|
||||
activity_serializer = activitypub.Rating
|
||||
pure_type = 'Note'
|
||||
|
||||
|
||||
class Boost(Status):
|
||||
''' boost'ing a post '''
|
||||
boosted_status = fields.ForeignKey(
|
||||
|
Reference in New Issue
Block a user