populate new authors with isni data
If a user selects an author pulled from the ISNI service when editing a book, use any relevant data from ISNI to populate the new author record. This includes - bio - aliases - isni - wikipedia url - viaf
This commit is contained in:
@ -11,7 +11,7 @@ from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
|
||||
from bookwyrm import book_search, forms, models
|
||||
from bookwyrm.utils.isni import find_authors_by_name
|
||||
from bookwyrm.utils.isni import find_authors_by_name, get_author_isni_data
|
||||
from bookwyrm.views.helpers import get_edition
|
||||
from .books import set_cover_from_url
|
||||
|
||||
@ -71,6 +71,8 @@ class EditBook(View):
|
||||
), # find matches from ISNI API
|
||||
}
|
||||
)
|
||||
# TODO: check if an isni record matches an existing record
|
||||
# to bring these two records together
|
||||
|
||||
# we're creating a new book
|
||||
if not book:
|
||||
@ -152,8 +154,13 @@ class ConfirmEditBook(View):
|
||||
models.Author, id=request.POST[f"author_match-{i}"]
|
||||
)
|
||||
except ValueError:
|
||||
# otherwise it's a name
|
||||
author = models.Author.objects.create(name=match)
|
||||
# otherwise it's a name with or without isni id
|
||||
isni = request.POST.get(f"isni_match-{i}")
|
||||
author_data = (
|
||||
get_author_isni_data(isni) if isni is not None
|
||||
else {"name": match}
|
||||
)
|
||||
author = models.Author.objects.create(**author_data)
|
||||
book.authors.add(author)
|
||||
|
||||
# create work, if needed
|
||||
|
Reference in New Issue
Block a user