Adds ReviewRating model

I can't just calling Rating because that would clash with the rating
field
This commit is contained in:
Mouse Reeve
2021-01-01 11:05:49 -08:00
parent 521934b4f3
commit 385ec4d70a
6 changed files with 86 additions and 8 deletions

View File

@ -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

View File

@ -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(