mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 16:40:36 +00:00
Fixes loading covers and authors
This commit is contained in:
parent
203e526a83
commit
0393d81230
4 changed files with 15 additions and 5 deletions
|
@ -15,7 +15,6 @@ class ActivityEncoder(JSONEncoder):
|
|||
@dataclass
|
||||
class Image:
|
||||
''' image block '''
|
||||
mediaType: str
|
||||
url: str
|
||||
type: str = 'Image'
|
||||
|
||||
|
|
|
@ -146,13 +146,11 @@ class AbstractConnector(ABC):
|
|||
|
||||
def create_book(self, remote_id, data, model):
|
||||
''' create a work or edition from data '''
|
||||
print(remote_id)
|
||||
book = model.objects.create(
|
||||
remote_id=remote_id,
|
||||
title=data['title'],
|
||||
connector=self.connector,
|
||||
)
|
||||
print(book.remote_id)
|
||||
return self.update_book_from_data(book, data)
|
||||
|
||||
|
||||
|
|
|
@ -41,9 +41,13 @@ class Connector(AbstractConnector):
|
|||
]
|
||||
|
||||
self.author_mappings = [
|
||||
Mapping('born', remote_field='birth_date', formatter=get_date),
|
||||
Mapping('died', remote_field='death_date', formatter=get_date),
|
||||
Mapping('name'),
|
||||
Mapping('bio'),
|
||||
Mapping('openlibrary_key'),
|
||||
Mapping('wikipedia_link'),
|
||||
Mapping('aliases'),
|
||||
Mapping('born', formatter=get_date),
|
||||
Mapping('died', formatter=get_date),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -58,6 +58,14 @@ class Book(ActivitypubMixin, BookWyrmModel):
|
|||
''' the activitypub serialization should be a list of author ids '''
|
||||
return [a.remote_id for a in self.authors.all()]
|
||||
|
||||
@property
|
||||
def ap_cover(self):
|
||||
''' an image attachment '''
|
||||
return [activitypub.Image(
|
||||
url='https://%s%s' % (DOMAIN, self.cover.url),
|
||||
)]
|
||||
|
||||
|
||||
activity_mappings = [
|
||||
ActivityMapping('id', 'remote_id'),
|
||||
|
||||
|
@ -90,6 +98,7 @@ class Book(ActivitypubMixin, BookWyrmModel):
|
|||
|
||||
ActivityMapping('lccn', 'lccn'),
|
||||
ActivityMapping('editions', 'editions_path'),
|
||||
ActivityMapping('attachment', 'ap_cover'),
|
||||
]
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
|
Loading…
Reference in a new issue