forked from mirrors/bookwyrm
Fixes bug that uses edition remote_id for work
This commit is contained in:
parent
277c1a80fd
commit
7220a17840
2 changed files with 7 additions and 5 deletions
|
@ -10,11 +10,13 @@ from fedireads.tasks import app
|
||||||
|
|
||||||
def get_or_create_book(value, key='id', connector_id=None):
|
def get_or_create_book(value, key='id', connector_id=None):
|
||||||
''' pull up a book record by whatever means possible '''
|
''' pull up a book record by whatever means possible '''
|
||||||
try:
|
book = models.Book.objects.select_subclasses().filter(
|
||||||
book = models.Book.objects.select_subclasses().get(**{key: value})
|
**{key: value}
|
||||||
|
).first()
|
||||||
|
if book:
|
||||||
|
if not isinstance(book, models.Edition):
|
||||||
|
return book.default_edition
|
||||||
return book
|
return book
|
||||||
except models.Book.DoesNotExist:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if key == 'remote_id':
|
if key == 'remote_id':
|
||||||
book = get_by_absolute_id(value, models.Book)
|
book = get_by_absolute_id(value, models.Book)
|
||||||
|
|
|
@ -71,7 +71,7 @@ class Connector(AbstractConnector):
|
||||||
|
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
# create both work and a default edition
|
# create both work and a default edition
|
||||||
work_key = edition_data.get('url')
|
work_key = work_data.get('url')
|
||||||
work = self.create_book(work_key, work_data, models.Work)
|
work = self.create_book(work_key, work_data, models.Work)
|
||||||
|
|
||||||
ed_key = edition_data.get('url')
|
ed_key = edition_data.get('url')
|
||||||
|
|
Loading…
Reference in a new issue