mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-28 11:00:36 +00:00
Fixes formatting isbn endpoint results
This commit is contained in:
parent
22af7ece71
commit
8c4cafed79
4 changed files with 11 additions and 11 deletions
|
@ -114,7 +114,7 @@ def search_title_author(query, min_confidence, *filters, return_first=False):
|
|||
editions_of_work = results.values("parent_work__id").values_list("parent_work__id")
|
||||
|
||||
# filter out multiple editions of the same work
|
||||
results = []
|
||||
list_results = []
|
||||
for work_id in set(editions_of_work):
|
||||
editions = results.filter(parent_work=work_id)
|
||||
default = editions.order_by("-edition_rank").first()
|
||||
|
@ -126,8 +126,8 @@ def search_title_author(query, min_confidence, *filters, return_first=False):
|
|||
result = editions.first()
|
||||
if return_first:
|
||||
return result
|
||||
results.append(result)
|
||||
return results
|
||||
list_results.append(result)
|
||||
return list_results
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
|
@ -119,12 +119,10 @@ class AbstractConnector(TestCase):
|
|||
@responses.activate
|
||||
def test_get_or_create_author(self):
|
||||
"""load an author"""
|
||||
self.connector.author_mappings = ( # pylint: disable=attribute-defined-outside-init
|
||||
[ # pylint: disable=attribute-defined-outside-init
|
||||
Mapping("id"),
|
||||
Mapping("name"),
|
||||
]
|
||||
)
|
||||
self.connector.author_mappings = [ # pylint: disable=attribute-defined-outside-init # pylint: disable=attribute-defined-outside-init
|
||||
Mapping("id"),
|
||||
Mapping("name"),
|
||||
]
|
||||
|
||||
responses.add(
|
||||
responses.GET,
|
||||
|
|
|
@ -35,7 +35,7 @@ class IsbnViews(TestCase):
|
|||
parent_work=self.work,
|
||||
)
|
||||
models.Connector.objects.create(
|
||||
identifier="self", connector_file="self_connector", local=True
|
||||
identifier="self", connector_file="self_connector"
|
||||
)
|
||||
models.SiteSettings.objects.create()
|
||||
|
||||
|
|
|
@ -17,7 +17,9 @@ class Isbn(View):
|
|||
book_results = book_search.isbn_search(isbn)
|
||||
|
||||
if is_api_request(request):
|
||||
return JsonResponse([r.json() for r in book_results], safe=False)
|
||||
return JsonResponse(
|
||||
[book_search.format_search_result(r) for r in book_results], safe=False
|
||||
)
|
||||
|
||||
paginated = Paginator(book_results, PAGE_LENGTH).get_page(
|
||||
request.GET.get("page")
|
||||
|
|
Loading…
Reference in a new issue