1
0
Fork 0

Activitypub serialize shelves

This commit is contained in:
Mouse Reeve 2020-05-09 21:52:13 -07:00
parent 932b4abcfe
commit 45e5df388d
6 changed files with 58 additions and 4 deletions

View file

@ -3,6 +3,7 @@ from django.utils import timezone
from django.db import models
from model_utils.managers import InheritanceManager
from fedireads import activitypub
from fedireads.settings import DOMAIN
from fedireads.utils.fields import JSONField, ArrayField
from fedireads.utils.models import FedireadsModel
@ -110,6 +111,10 @@ class Book(FedireadsModel):
self.title,
)
@property
def activitypub_serialize(self):
return activitypub.get_book(self)
class Work(Book):
''' a work (an abstract concept of a book that manifests in an edition) '''
@ -165,3 +170,7 @@ class Author(FedireadsModel):
models.CharField(max_length=255), blank=True, default=list
)
bio = models.TextField(null=True, blank=True)
@property
def activitypub_serialize(self):
return activitypub.get_author(self)

View file

@ -1,6 +1,7 @@
''' puttin' books on shelves '''
from django.db import models
from fedireads import activitypub
from fedireads.utils.models import FedireadsModel
@ -23,6 +24,10 @@ class Shelf(FedireadsModel):
model_name = type(self).__name__.lower()
return '%s/%s/%s' % (base_path, model_name, self.identifier)
@property
def activitypub_serialize(self):
return activitypub.get_shelf(self)
class Meta:
unique_together = ('user', 'identifier')