-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
0a1b9ef
commit 9e1eb3f
Showing
7 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
Поиск<br> | ||
<form action="search/node" method="GET"> | ||
<input type="search" name="query" /> | ||
<input type="submit" value="search" /> | ||
</form> | ||
ВК-виджет<br> | ||
Ссылки |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block title %}Search{% endblock %} | ||
|
||
{% block content %} | ||
{% if search_results %} | ||
<ul> | ||
{% for result in search_results %} | ||
<li> | ||
<h4><a href="{{ result.specific.url }}">{{ result }}</a></h4> | ||
{% if result.search_description %} | ||
{{ result.search_description|safe }} | ||
{% endif %} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% elif search_query %} | ||
No results found | ||
{% else %} | ||
Please type something into the search box | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.urls import path | ||
from . import views | ||
|
||
urlpatterns = [ | ||
path('search/node', views.search, name='search'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
from django.shortcuts import render | ||
from django.http import HttpResponse | ||
from wagtail.core.models import Page | ||
|
||
# Create your views here. | ||
def search(request): | ||
search_query = request.GET.get('query', None) | ||
if search_query: | ||
search_results = Page.objects.live().search(search_query) | ||
else: | ||
search_results = Page.objects.none() | ||
|
||
return render(request, 'search.html', { | ||
'search_query': search_query, | ||
'search_results': search_results, | ||
}) |