Skip to content

Commit

Permalink
Upgrade to Wagtail 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mgax committed Nov 29, 2023
1 parent 5d2fb02 commit 72a96f6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
3 changes: 2 additions & 1 deletion ietf/search/templates/search/search.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends settings.utils.LayoutSettings.base_template %}
{% load static wagtailcore_tags %}
{% load static wagtailcore_tags wagtailsearchpromotions_tags %}

{% block title %}Search{% endblock %}

Expand Down Expand Up @@ -38,6 +38,7 @@ <h1>Search results for {{ SITE.hostname }}</h1>
<div class="col-12 col-lg-8 pt-3 pt-lg-5 pe-lg-3">
<div class="u-max-text-width pb-4">

{% get_search_promotions search_query as search_picks %}
{% if search_picks %}
<h2 class="visually-hidden">Search results{% if search_query %} for "{{ search_query }}"{% endif %}</h2>
<ul class="list-unstyled">
Expand Down
12 changes: 2 additions & 10 deletions ietf/search/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.shortcuts import render
from wagtail.contrib.search_promotions.models import SearchPromotion
from wagtail.models import Page
from wagtail.search.models import Query
from wagtail.contrib.search_promotions.models import Query


def search(request):
Expand All @@ -12,16 +11,10 @@ def search(request):
# Search
if search_query and "\x00" not in search_query:
search_results = Page.objects.live().search(search_query)
query = Query.get(search_query)
Query.get(search_query).add_hit()

# Record hit
query.add_hit()

# Get search picks
search_picks = query.editors_picks.all()
else:
search_results = Page.objects.none()
search_picks = SearchPromotion.objects.none()

# Pagination
paginator = Paginator(search_results, 10)
Expand All @@ -38,6 +31,5 @@ def search(request):
{
"search_query": search_query,
"search_results": search_results,
"search_picks": search_picks,
},
)
6 changes: 3 additions & 3 deletions ietf/snippets/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Charter(models.Model, index.Indexed):
)

search_fields = [
index.SearchField("title", partial_match=True, boost=10),
index.SearchField("title", boost=10),
index.SearchField("abstract"),
]

Expand Down Expand Up @@ -61,7 +61,7 @@ class WorkingGroup(models.Model, index.Indexed):
# There is no field currently to capture area/parent

search_fields = [
index.SearchField("name", partial_match=True, boost=10),
index.SearchField("name", boost=10),
index.SearchField("acronym"),
index.SearchField("description"),
]
Expand Down Expand Up @@ -102,7 +102,7 @@ class RFC(models.Model, index.Indexed):
)

search_fields = [
index.SearchField("title", partial_match=True, boost=10),
index.SearchField("title", boost=10),
index.SearchField("rfc", boost=10),
index.SearchField("authors"),
index.SearchField("abstract"),
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ addopts = "--reuse-db"
python_files = "ietf/*/test*.py"
filterwarnings = [
"error",
"ignore::DeprecationWarning:willow.image",
"ignore::DeprecationWarning:l18n.translation",
"ignore:'imghdr' is deprecated:DeprecationWarning:wagtail.images.views.serve",
"ignore::UserWarning",
]
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ tqdm>=3.7.0
typed-environment-configuration>=0.1.3,<0.2
wagtail-markdown
wagtail-orderable
wagtail>=4.2,<4.3
wagtail>=5.0,<5.1
10 changes: 7 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ chardet==5.2.0
# via mbstrdecoder
charset-normalizer==3.3.2
# via requests
defusedxml==0.7.1
# via willow
dj-database-url==0.5.0
# via -r base.in
django==4.1.13
Expand Down Expand Up @@ -48,6 +50,8 @@ draftjs-exporter==2.1.7
# via wagtail
et-xmlfile==1.1.0
# via openpyxl
filetype==1.2.0
# via willow
html5lib==1.1
# via wagtail
idna==3.6
Expand All @@ -62,7 +66,7 @@ openpyxl==3.1.2
# via wagtail
packaging==23.2
# via bleach
pillow==9.5.0
pillow==10.1.0
# via wagtail
psycopg2-binary==2.9.9
# via -r base.in
Expand Down Expand Up @@ -94,7 +98,7 @@ typepy==1.3.0
# via typed-environment-configuration
urllib3==2.1.0
# via requests
wagtail==4.2.4
wagtail==5.0.5
# via
# -r base.in
# wagtail-markdown
Expand All @@ -107,5 +111,5 @@ webencodings==0.5.1
# via
# bleach
# html5lib
willow==1.4.1
willow==1.6.3
# via wagtail

0 comments on commit 72a96f6

Please sign in to comment.