diff --git a/mpicms/base/models.py b/mpicms/base/models.py index be5fc74..415d5ed 100644 --- a/mpicms/base/models.py +++ b/mpicms/base/models.py @@ -92,6 +92,10 @@ class CategoryPage(NewsMixin, Page): panels=None), ] + search_fields = Page.search_fields + [ + index.SearchField('body'), + ] + parent_page_types = ['HomePage', 'CategoryPage'] @property @@ -113,7 +117,6 @@ class WikiPage(CategoryMixin, Page): search_fields = Page.search_fields + [ index.SearchField('body'), - index.FilterField('date'), ] content_panels = Page.content_panels + [ diff --git a/mpicms/base/views.py b/mpicms/base/views.py new file mode 100644 index 0000000..a016b84 --- /dev/null +++ b/mpicms/base/views.py @@ -0,0 +1,27 @@ +from django.shortcuts import render + +from wagtail.core.models import Page +from django.core.paginator import Paginator +from wagtail.search.models import Query + + +def search(request): + search_query = request.GET.get('query', None) + if search_query: + search_results = Page.objects.live().search(search_query) + + # Log the query so Wagtail can suggest promoted results + Query.get(search_query).add_hit() + else: + search_results = Page.objects.none() + + paginator = Paginator(search_results, 8) + + page = request.GET.get('page') + search_results = paginator.get_page(page) + + return render(request, 'base/search_results.html', { + 'paginator': paginator, + 'search_query': search_query, + 'search_results': search_results, + }) diff --git a/mpicms/news/models.py b/mpicms/news/models.py index 8f7835a..f31b23e 100644 --- a/mpicms/news/models.py +++ b/mpicms/news/models.py @@ -5,6 +5,7 @@ from wagtail.core.models import Page from wagtail.core.fields import RichTextField from wagtail.admin.edit_handlers import FieldPanel +from wagtail.search import index from mpicms.base.models import CategoryMixin @@ -18,7 +19,7 @@ class NewsPage(CategoryMixin, Page): parent_page_types = ['base.CategoryPage', 'base.HomePage'] subpage_types = ['NewsEntry'] show_in_menus_default = False - paginated_by = 2 + paginated_by = 8 def get_context(self, request, *args, **kwargs): context = super().get_context(request, *args, **kwargs) @@ -59,6 +60,12 @@ class NewsEntry(CategoryMixin, Page): FieldPanel('body', classname="full"), ] + search_fields = Page.search_fields + [ + index.SearchField('body'), + index.SearchField('preview'), + index.FilterField('date') + ] + parent_page_types = ['NewsPage'] class Meta: # noqa diff --git a/mpicms/static/css/custom.css b/mpicms/static/css/custom.css index 50b9506..595f569 100644 --- a/mpicms/static/css/custom.css +++ b/mpicms/static/css/custom.css @@ -13,6 +13,10 @@ select, input { border-radius: 0 !important; } +.content .fa-chevron-right { + padding-left: 1em; +} + .title { font-family: "Merriweather", serif; font-weight: 400; @@ -231,6 +235,20 @@ select, input { float: right; } +.card-head { + /* font-color: gray !important; */ + padding: 0 !important; + margin: 0 0 0.8em 0 !important; +} + +.card-head a { + color: #4a4a4a; +} + +.card-head a:hover { + color: black; +} + .section-button { display: flex; align-items: center; @@ -250,6 +268,11 @@ select, input { border-color: #006c66; } +.is-important .card-content{ + /* background-color: #eeeeee */ + border: 1px solid grey; +} + /* Full Calendar */ .fc-button { border-radius: 0 !important; diff --git a/mpicms/templates/base/components/pagination.html b/mpicms/templates/base/components/pagination.html index e1635fd..7b4bf43 100644 --- a/mpicms/templates/base/components/pagination.html +++ b/mpicms/templates/base/components/pagination.html @@ -1,5 +1,7 @@ {% load url_tags %} +{% if paginator.num_pages > 1 %} + {% firstof items.number '1' as current %} - \ No newline at end of file +{% endif %} \ No newline at end of file diff --git a/mpicms/templates/base/search_results.html b/mpicms/templates/base/search_results.html new file mode 100644 index 0000000..230dfe3 --- /dev/null +++ b/mpicms/templates/base/search_results.html @@ -0,0 +1,70 @@ +{% extends "base.html" %} +{% load wagtailcore_tags wagtailsearchpromotions_tags %} + +{% block title %}Search{% endblock %} + +{% block content %} +
No results found
+ {% else %} +Please type something into the search box
+ {% endif %} + {% endif %} + +