-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsearch.py
55 lines (45 loc) · 1.46 KB
/
search.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from __future__ import annotations
from onegov.core.security import Personal
from onegov.fsi import FsiApp
from onegov.fsi.layout import DefaultLayout
from onegov.org.models import Search, SearchPostgres
from onegov.org.views.search import (search, search_postgres,
suggestions, suggestions_postgres)
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from onegov.core.orm import Base
from onegov.core.types import JSON_ro, RenderData
from onegov.fsi.request import FsiRequest
from webob import Response
@FsiApp.html(
model=Search,
template='search.pt',
permission=Personal
)
def fsi_search(
self: Search[Base],
request: FsiRequest
) -> RenderData | Response:
return search(self, request, DefaultLayout(self, request))
@FsiApp.html(
model=SearchPostgres,
template='search_postgres.pt',
permission=Personal
)
def fsi_search_postgres(
self: SearchPostgres[Base],
request: FsiRequest
) -> RenderData | Response:
return search_postgres(self, request, DefaultLayout(self, request))
@FsiApp.json(model=Search, name='suggest', permission=Personal)
def fsi_suggestions(
self: Search[Base],
request: FsiRequest
) -> JSON_ro:
return suggestions(self, request)
@FsiApp.json(model=SearchPostgres, name='suggest', permission=Personal)
def fsi_suggestions_postgres(
self: SearchPostgres[Base],
request: FsiRequest
) -> JSON_ro:
return suggestions_postgres(self, request)