parent
be4f41335e
commit
ff96835c2a
5 changed files with 43 additions and 15 deletions
|
@ -128,9 +128,10 @@ class AbstractConnector(ABC):
|
|||
if not edition:
|
||||
ed_key = self.get_remote_id_from_data(edition_data)
|
||||
edition = self.create_book(ed_key, edition_data, models.Edition)
|
||||
edition.default = True
|
||||
edition.parent_work = work
|
||||
edition.save()
|
||||
work.default_edition = edition
|
||||
work.save()
|
||||
|
||||
# now's our change to fill in author gaps
|
||||
if not edition.authors and work.authors:
|
||||
|
|
|
@ -72,7 +72,6 @@ class Connector(AbstractConnector):
|
|||
]
|
||||
|
||||
|
||||
|
||||
def get_remote_id_from_data(self, data):
|
||||
try:
|
||||
key = data['key']
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
''' using a bookwyrm instance as a source of book data '''
|
||||
from django.contrib.postgres.search import SearchRank, SearchVector
|
||||
from django.db.models import F
|
||||
|
||||
from bookwyrm import models
|
||||
from .abstract_connector import AbstractConnector, SearchResult
|
||||
|
@ -30,7 +31,10 @@ class Connector(AbstractConnector):
|
|||
).filter(
|
||||
rank__gt=min_confidence
|
||||
).order_by('-rank')
|
||||
results = results.filter(default=True) or results
|
||||
|
||||
# remove non-default editions, if possible
|
||||
results = results.filter(parent_work__default_edition__id=F('id')) \
|
||||
or results
|
||||
|
||||
search_results = []
|
||||
for book in results[:10]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue