Source code for org.views.search

from __future__ import annotations

import morepath
import transaction

from onegov.core.security import Public
from onegov.org import _, OrgApp
from onegov.org.elements import Link
from onegov.org.layout import DefaultLayout
from onegov.org.forms import SearchForm
from onegov.org.models import Search
from onegov.search import SearchOfflineError
from sqlalchemy.exc import InternalError
from webob import exc


from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from onegov.core.types import JSON_ro, RenderData
    from onegov.org.request import OrgRequest
    from webob import Response


@OrgApp.html(model=Search, template='search.pt', permission=Public)




@OrgApp.json(model=Search, name='suggest', permission=Public)
[docs] def suggestions(self: Search, request: OrgRequest) -> JSON_ro: try: return self.suggestions() except SearchOfflineError as exception: raise exc.HTTPNotFound() from exception