User ordered collection subtype for shelves
This commit is contained in:
parent
e61d8b7638
commit
f42a5444e5
|
@ -10,7 +10,7 @@ from .note import Note, GeneratedNote, Article, Comment, Review, Quotation
|
||||||
from .note import Tombstone
|
from .note import Tombstone
|
||||||
from .interaction import Boost, Like
|
from .interaction import Boost, Like
|
||||||
from .ordered_collection import OrderedCollection, OrderedCollectionPage
|
from .ordered_collection import OrderedCollection, OrderedCollectionPage
|
||||||
from .ordered_collection import BookList
|
from .ordered_collection import BookList, Shelf
|
||||||
from .person import Person, PublicKey
|
from .person import Person, PublicKey
|
||||||
from .response import ActivitypubResponse
|
from .response import ActivitypubResponse
|
||||||
from .book import Edition, Work, Author
|
from .book import Edition, Work, Author
|
||||||
|
|
|
@ -13,13 +13,20 @@ class OrderedCollection(ActivityObject):
|
||||||
last: str = None
|
last: str = None
|
||||||
name: str = None
|
name: str = None
|
||||||
owner: str = None
|
owner: str = None
|
||||||
to: List[str] = field(default_factory=lambda: [])
|
|
||||||
cc: List[str] = field(default_factory=lambda: [])
|
|
||||||
type: str = 'OrderedCollection'
|
type: str = 'OrderedCollection'
|
||||||
|
|
||||||
|
@dataclass(init=False)
|
||||||
|
class OrderedCollectionPrivate(OrderedCollection):
|
||||||
|
to: List[str] = field(default_factory=lambda: [])
|
||||||
|
cc: List[str] = field(default_factory=lambda: [])
|
||||||
|
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class BookList(OrderedCollection):
|
class Shelf(OrderedCollectionPrivate):
|
||||||
|
''' structure of an ordered collection activity '''
|
||||||
|
type: str = 'Shelf'
|
||||||
|
|
||||||
|
@dataclass(init=False)
|
||||||
|
class BookList(OrderedCollectionPrivate):
|
||||||
''' structure of an ordered collection activity '''
|
''' structure of an ordered collection activity '''
|
||||||
summary: str = None
|
summary: str = None
|
||||||
curation: str = 'closed'
|
curation: str = 'closed'
|
||||||
|
|
|
@ -229,6 +229,7 @@ class OrderedCollectionPageMixin(ActivitypubMixin):
|
||||||
serializer = self.activity_serializer
|
serializer = self.activity_serializer
|
||||||
# a dict from the model fields
|
# a dict from the model fields
|
||||||
activity = generate_activity(self)
|
activity = generate_activity(self)
|
||||||
|
|
||||||
if remote_id:
|
if remote_id:
|
||||||
activity['id'] = remote_id
|
activity['id'] = remote_id
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel):
|
||||||
through_fields=('shelf', 'book')
|
through_fields=('shelf', 'book')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
activity_serializer = activitypub.Shelf
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
''' set the identifier '''
|
''' set the identifier '''
|
||||||
saved = super().save(*args, **kwargs)
|
saved = super().save(*args, **kwargs)
|
||||||
|
|
Loading…
Reference in New Issue