Search cleanup
This commit is contained in:
@ -53,21 +53,13 @@ class ImportItem(models.Model):
|
||||
def resolve(self):
|
||||
''' try various ways to lookup a book '''
|
||||
self.book = (
|
||||
self.get_book_from_db_isbn() or
|
||||
self.get_book_from_isbn() or
|
||||
self.get_book_from_title_author()
|
||||
)
|
||||
|
||||
def get_book_from_db_isbn(self):
|
||||
''' see if we already know about the book '''
|
||||
try:
|
||||
return Edition.objects.filter(isbn_13=self.isbn).first()
|
||||
except Edition.DoesNotExist:
|
||||
return None
|
||||
|
||||
def get_book_from_isbn(self):
|
||||
''' search by isbn '''
|
||||
search_result = books_manager.search(self.isbn, first=True)
|
||||
search_result = books_manager.first_search_result(self.isbn)
|
||||
if search_result:
|
||||
return books_manager.get_or_create_book(search_result.key)
|
||||
|
||||
@ -77,7 +69,7 @@ class ImportItem(models.Model):
|
||||
self.data['Title'],
|
||||
self.data['Author']
|
||||
)
|
||||
search_result = books_manager.search(search_term, first=True)
|
||||
search_result = books_manager.first_search_result(search_term)
|
||||
if search_result:
|
||||
return books_manager.get_or_create_book(search_result.key)
|
||||
|
||||
|
Reference in New Issue
Block a user