Separate out local and remote search results

This commit is contained in:
Mouse Reeve
2020-05-03 12:59:06 -07:00
parent d8934879e9
commit 7fb0a87077
8 changed files with 102 additions and 41 deletions

View File

@ -16,14 +16,17 @@ ConnectorFiles = models.TextChoices('ConnectorFiles', CONNECTORS)
class Connector(FedireadsModel):
''' book data source connectors '''
identifier = models.CharField(max_length=255, unique=True)
priority = models.IntegerField(default=2)
name = models.CharField(max_length=255, null=True)
self = models.BooleanField(default=False)
connector_file = models.CharField(
max_length=255,
default='openlibrary',
choices=ConnectorFiles.choices
)
api_key = models.CharField(max_length=255, null=True)
base_url = models.CharField(max_length=255)
books_url = models.CharField(max_length=255)
covers_url = models.CharField(max_length=255)
search_url = models.CharField(max_length=255, null=True)

View File

@ -67,9 +67,9 @@ class ImportItem(models.Model):
def get_book_from_isbn(self):
''' search by isbn '''
search_results = books_manager.search(self.isbn)
if search_results:
return books_manager.get_or_create_book(search_results[0].key)
search_result = books_manager.search(self.isbn, first=True)
if search_result:
return books_manager.get_or_create_book(search_result.key)
def get_book_from_title_author(self):
''' search by title and author '''
@ -77,9 +77,9 @@ class ImportItem(models.Model):
self.data['Title'],
self.data['Author']
)
search_results = books_manager.search(search_term)
if search_results:
return books_manager.get_or_create_book(search_results[0].key)
search_result = books_manager.search(search_term, first=True)
if search_result:
return books_manager.get_or_create_book(search_result.key)
@property
def isbn(self):