from django.urls import reverse

from oscar.core.loading import get_class

SearchForm = get_class("search.forms", "SearchForm")


def search_form(request):
    """
    Ensure that the search form is available site wide, except admin pages
    """
    if request.path.startswith(reverse("wagtailadmin_home")):
        return {}
    return {"search_form": SearchForm(request.GET)}
