Use search results template for isbn view
This commit is contained in:
parent
053579c2a4
commit
85a4c331eb
|
@ -1,33 +0,0 @@
|
||||||
{% extends 'layout.html' %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block title %}{% trans "Search Results" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
{% with book_results|first as local_results %}
|
|
||||||
<div class="block">
|
|
||||||
<h1 class="title">{% blocktrans %}Search Results for "{{ query }}"{% endblocktrans %}</h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="block columns">
|
|
||||||
<div class="column">
|
|
||||||
<h2 class="title">{% trans "Matching Books" %}</h2>
|
|
||||||
<section class="block">
|
|
||||||
{% if not results %}
|
|
||||||
<p>{% blocktrans %}No books found for "{{ query }}"{% endblocktrans %}</p>
|
|
||||||
{% else %}
|
|
||||||
<ul>
|
|
||||||
{% for result in results %}
|
|
||||||
<li class="pd-4">
|
|
||||||
<a href="{{ result.key }}">{% include 'snippets/search_result_text.html' with result=result link=True %}</a>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<div class="column">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endwith %}
|
|
||||||
{% endblock %}
|
|
|
@ -1,9 +1,11 @@
|
||||||
""" isbn search view """
|
""" isbn search view """
|
||||||
|
from django.core.paginator import Paginator
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.views import View
|
from django.views import View
|
||||||
|
|
||||||
from bookwyrm.connectors import connector_manager
|
from bookwyrm.connectors import connector_manager
|
||||||
|
from bookwyrm.settings import PAGE_LENGTH
|
||||||
from .helpers import is_api_request
|
from .helpers import is_api_request
|
||||||
|
|
||||||
# pylint: disable= no-self-use
|
# pylint: disable= no-self-use
|
||||||
|
@ -17,8 +19,12 @@ class Isbn(View):
|
||||||
if is_api_request(request):
|
if is_api_request(request):
|
||||||
return JsonResponse([r.json() for r in book_results], safe=False)
|
return JsonResponse([r.json() for r in book_results], safe=False)
|
||||||
|
|
||||||
|
paginated = Paginator(book_results, PAGE_LENGTH).get_page(
|
||||||
|
request.GET.get("page")
|
||||||
|
)
|
||||||
data = {
|
data = {
|
||||||
"results": book_results,
|
"results": [{"results": paginated}],
|
||||||
"query": isbn,
|
"query": isbn,
|
||||||
|
"type": "book",
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, "isbn_search_results.html", data)
|
return TemplateResponse(request, "search/book.html", data)
|
||||||
|
|
Loading…
Reference in New Issue