Convert the API to use viewsets. The search function is now a service of the search model resource. The simple and advance search are now the same service. The difference is determined by the URL query. A ?q= means a simple search. For advanced search pass the search model fields in the URL query, example: ?q=document_type__label= Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
33 lines
863 B
Python
33 lines
863 B
Python
from __future__ import unicode_literals
|
|
|
|
from django.conf.urls import url
|
|
|
|
from .api_views import SearchModelAPIViewSet
|
|
from .views import AdvancedSearchView, ResultsView, SearchAgainView, SearchView
|
|
|
|
urlpatterns = [
|
|
url(
|
|
regex=r'^(?P<search_model>[\.\w]+)/$', name='search',
|
|
view=SearchView.as_view()
|
|
),
|
|
url(
|
|
regex=r'^advanced/(?P<search_model>[\.\w]+)/$', name='search_advanced',
|
|
view=AdvancedSearchView.as_view()
|
|
),
|
|
url(
|
|
regex=r'^again/(?P<search_model>[\.\w]+)/$', name='search_again',
|
|
view=SearchAgainView.as_view()
|
|
),
|
|
url(
|
|
regex=r'^results/(?P<search_model>[\.\w]+)/$', name='results',
|
|
view=ResultsView.as_view()
|
|
)
|
|
]
|
|
|
|
api_router_entries = (
|
|
{
|
|
'prefix': r'search_models', 'viewset': SearchModelAPIViewSet,
|
|
'basename': 'search_model'
|
|
},
|
|
)
|