Search cleanup
This commit is contained in:
parent
3094e2b539
commit
855b4a4eb0
2 changed files with 19 additions and 21 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue