Only allow GET for search results

This commit is contained in:
Jake Howard 2022-08-01 21:42:06 +01:00
parent 750ed5aa39
commit 5b4ff2b4e9
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -2,7 +2,9 @@ from django.core.paginator import EmptyPage, Paginator
from django.http.request import HttpRequest
from django.http.response import HttpResponse, HttpResponseBadRequest
from django.shortcuts import render
from django.utils.decorators import method_decorator
from django.utils.functional import cached_property
from django.views.decorators.http import require_GET
from rest_framework import serializers
from wagtail.contrib.routable_page.models import RoutablePageMixin, route
from wagtail.models import Page
@ -45,6 +47,7 @@ class SearchPage(BaseContentMixin, RoutablePageMixin, BasePage): # type: ignore
return context
@route(r"^results/$")
@method_decorator(require_GET)
def results(self, request: HttpRequest) -> HttpResponse:
if not request.GET.get("q", None):
return HttpResponse()