Source code for org.views.search

from __future__ import annotations

import morepath

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.models import Search
from onegov.search import SearchOfflineError
from webob import exc


from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from onegov.core.orm import Base
    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[Base], request: OrgRequest) -> JSON_ro: try: return self.suggestions() except SearchOfflineError as exception: raise exc.HTTPNotFound() from exception