Skip to content
Snippets Groups Projects
Commit d470f289 authored by jan.bednarik's avatar jan.bednarik
Browse files

search: Remove unused default search app

parent 4d401212
No related branches found
No related tags found
2 merge requests!446Release,!445Menu
......@@ -41,7 +41,6 @@ Rozšíření která používáme:
├── majak = Django projekt s konfigurací Majáku
├── shared = app se sdílenými static soubory a templaty pro weby
├── calendar_utils = app s modelem a utilitami na iCal kalendáře
├── search = app pro fulltext search (default, asi se k ničemu nepoužívá)
├── tuning = app na tuning administračního rozhraní Majáku
└── users = app s custom user modelem a SSO, apod.
......
......@@ -47,7 +47,6 @@ INSTALLED_APPS = [
"users",
"pirates",
"tuning",
"search",
"regulace_konopi",
"green_deal",
"elections2021",
......
......@@ -8,7 +8,6 @@ from wagtail.core import urls as wagtail_urls
from wagtail.documents import urls as wagtaildocs_urls
from elections2021 import views as elections2021_views
from search import views as search_views
handler404 = "shared.views.page_not_found"
......@@ -16,7 +15,6 @@ urlpatterns = [
path("django-admin/", admin.site.urls),
path("admin/", include(wagtailadmin_urls)),
path("documents/", include(wagtaildocs_urls)),
path("search/", search_views.search, name="search"),
path(
"export/elections2021/banner-orders.csv",
elections2021_views.banner_orders_csv,
......
{% extends "base.html" %}
{% load static wagtailcore_tags %}
{% block body_class %}template-searchresults{% endblock %}
{% block title %}Search{% endblock %}
{% block content %}
<h1>Search</h1>
<form action="{% url 'search' %}" method="get">
<input type="text" name="query"{% if search_query %} value="{{ search_query }}"{% endif %}>
<input type="submit" value="Search" class="button">
</form>
{% if search_results %}
<ul>
{% for result in search_results %}
<li>
<h4><a href="{% pageurl result %}">{{ result }}</a></h4>
{% if result.search_description %}
{{ result.search_description }}
{% endif %}
</li>
{% endfor %}
</ul>
{% if search_results.has_previous %}
<a href="{% url 'search' %}?query={{ search_query|urlencode }}&amp;page={{ search_results.previous_page_number }}">Previous</a>
{% endif %}
{% if search_results.has_next %}
<a href="{% url 'search' %}?query={{ search_query|urlencode }}&amp;page={{ search_results.next_page_number }}">Next</a>
{% endif %}
{% elif search_query %}
No results found
{% endif %}
{% endblock %}
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.shortcuts import render
from wagtail.core.models import Page
from wagtail.search.models import Query
def search(request):
search_query = request.GET.get("query", None)
page = request.GET.get("page", 1)
# Search
if search_query:
search_results = Page.objects.live().search(search_query)
query = Query.get(search_query)
# Record hit
query.add_hit()
else:
search_results = Page.objects.none()
# Pagination
paginator = Paginator(search_results, 10)
try:
search_results = paginator.page(page)
except PageNotAnInteger:
search_results = paginator.page(1)
except EmptyPage:
search_results = paginator.page(paginator.num_pages)
return render(
request,
"search/search.html",
{
"search_query": search_query,
"search_results": search_results,
},
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment