Fixes for goodreads import + ol changes

This commit is contained in:
Mouse Reeve 2020-03-31 18:58:13 -07:00
parent ca26a712c3
commit 0a8d080b62
2 changed files with 8 additions and 3 deletions

View file

@ -167,7 +167,7 @@ class Connector(AbstractConnector):
}
author = update_from_mappings(author, data, mappings)
# TODO this is making some BOLD assumption
name = data['name']
name = data.get('name')
author.last_name = name.split(' ')[-1]
author.first_name = ' '.join(name.split(' ')[:-1])
author.save()
@ -204,8 +204,9 @@ def set_default_edition(work):
options,
key=lambda e: e.published_date.year if e.published_date else None
)
options[0].default = True
options[0].save()
if len(options):
options[0].default = True
options[0].save()
def get_description(description_blob):

View file

@ -167,6 +167,10 @@ def handle_import_books(user, items):
identifier=item.shelf,
user=user
)
if isinstance(item.book, models.Work):
item.book = item.book.default_edition
if not item.book:
continue
_, created = models.ShelfBook.objects.get_or_create(
book=item.book, shelf=desired_shelf, added_by=user)
if created: