mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-15 13:24:04 +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 Tombstone
|
||||
from .ordered_collection import OrderedCollection, OrderedCollectionPage
|
||||
from .ordered_collection import CollectionItem, ListItem, ShelfItem
|
||||
from .ordered_collection import BookList, Shelf
|
||||
from .person import Person, PublicKey
|
||||
from .response import ActivitypubResponse
|
||||
|
|
|
@ -50,3 +50,27 @@ class OrderedCollectionPage(ActivityObject):
|
|||
next: str = None
|
||||
prev: str = None
|
||||
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 .base_activity import ActivityObject, Signature, resolve_remote_id
|
||||
from .book import Edition
|
||||
from .ordered_collection import CollectionItem
|
||||
|
||||
|
||||
@dataclass(init=False)
|
||||
|
@ -141,12 +141,9 @@ class Reject(Verb):
|
|||
class Add(Verb):
|
||||
"""Add activity """
|
||||
|
||||
target: str
|
||||
object: Edition
|
||||
target: ActivityObject
|
||||
object: CollectionItem
|
||||
type: str = "Add"
|
||||
notes: str = None
|
||||
order: int = 0
|
||||
approved: bool = True
|
||||
|
||||
def action(self):
|
||||
""" add obj to collection """
|
||||
|
@ -159,10 +156,9 @@ class Add(Verb):
|
|||
|
||||
|
||||
@dataclass(init=False)
|
||||
class Remove(Verb):
|
||||
class Remove(Add):
|
||||
"""Remove activity """
|
||||
|
||||
target: ActivityObject
|
||||
type: str = "Remove"
|
||||
|
||||
def action(self):
|
||||
|
|
Loading…
Reference in a new issue