Separate out local and remote search results
This commit is contained in:
@ -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)
|
||||
|
||||
|
@ -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):
|
||||
|
Reference in New Issue
Block a user