mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-03 05:48:44 +00:00
Use CollectionItem objects
This commit is contained in:
parent
6617cede37
commit
98161b9041
3 changed files with 29 additions and 8 deletions
|
@ -10,6 +10,7 @@ from .note import Note, GeneratedNote, Article, Comment, Quotation
|
||||||
from .note import Review, Rating
|
from .note import Review, Rating
|
||||||
from .note import Tombstone
|
from .note import Tombstone
|
||||||
from .ordered_collection import OrderedCollection, OrderedCollectionPage
|
from .ordered_collection import OrderedCollection, OrderedCollectionPage
|
||||||
|
from .ordered_collection import CollectionItem, ListItem, ShelfItem
|
||||||
from .ordered_collection import BookList, Shelf
|
from .ordered_collection import BookList, Shelf
|
||||||
from .person import Person, PublicKey
|
from .person import Person, PublicKey
|
||||||
from .response import ActivitypubResponse
|
from .response import ActivitypubResponse
|
||||||
|
|
|
@ -50,3 +50,27 @@ class OrderedCollectionPage(ActivityObject):
|
||||||
next: str = None
|
next: str = None
|
||||||
prev: str = None
|
prev: str = None
|
||||||
type: str = "OrderedCollectionPage"
|
type: str = "OrderedCollectionPage"
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(init=False)
|
||||||
|
class CollectionItem(ActivityObject):
|
||||||
|
""" an item in a collection """
|
||||||
|
actor: str
|
||||||
|
type: str = "CollectionItem"
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(init=False)
|
||||||
|
class ListItem(CollectionItem):
|
||||||
|
""" a book on a list """
|
||||||
|
book: str
|
||||||
|
notes: str = None
|
||||||
|
approved: bool = True
|
||||||
|
order: int = None
|
||||||
|
type: str = "ListItem"
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(init=False)
|
||||||
|
class ShelfItem(CollectionItem):
|
||||||
|
""" a book on a list """
|
||||||
|
book: str
|
||||||
|
type: str = "ShelfItem"
|
||||||
|
|
|
@ -4,7 +4,7 @@ from typing import List
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
|
||||||
from .base_activity import ActivityObject, Signature, resolve_remote_id
|
from .base_activity import ActivityObject, Signature, resolve_remote_id
|
||||||
from .book import Edition
|
from .ordered_collection import CollectionItem
|
||||||
|
|
||||||
|
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
|
@ -141,12 +141,9 @@ class Reject(Verb):
|
||||||
class Add(Verb):
|
class Add(Verb):
|
||||||
"""Add activity """
|
"""Add activity """
|
||||||
|
|
||||||
target: str
|
target: ActivityObject
|
||||||
object: Edition
|
object: CollectionItem
|
||||||
type: str = "Add"
|
type: str = "Add"
|
||||||
notes: str = None
|
|
||||||
order: int = 0
|
|
||||||
approved: bool = True
|
|
||||||
|
|
||||||
def action(self):
|
def action(self):
|
||||||
""" add obj to collection """
|
""" add obj to collection """
|
||||||
|
@ -159,10 +156,9 @@ class Add(Verb):
|
||||||
|
|
||||||
|
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class Remove(Verb):
|
class Remove(Add):
|
||||||
"""Remove activity """
|
"""Remove activity """
|
||||||
|
|
||||||
target: ActivityObject
|
|
||||||
type: str = "Remove"
|
type: str = "Remove"
|
||||||
|
|
||||||
def action(self):
|
def action(self):
|
||||||
|
|
Loading…
Reference in a new issue