diff --git a/requirements/requirements.txt b/requirements/requirements.txt index a60ca4e8c..e613509e7 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,5 +1,5 @@ django==2.2.13 -django-haystack==2.8.1 +django-haystack==3.0 django-filter==2.0.0 djangorestframework==3.9.1 dj-database-url==0.5.0 diff --git a/sapl/base/views.py b/sapl/base/views.py index ad0051d9f..df07e3764 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -2207,6 +2207,7 @@ class AppConfigCrud(CrudAux): def get(self, request, *args, **kwargs): return HttpResponseRedirect(reverse('sapl.base:appconfig_create')) + class HackedFacetedModelSearchForm(FacetedModelSearchForm): """ Este é um hack vindo de https://github.com/django-haystack/django-haystack/pull/705 @@ -2219,28 +2220,10 @@ class HackedFacetedModelSearchForm(FacetedModelSearchForm): super().__init__(*args, **kwargs) -# class SaplSearchView(FacetedSearchView): -# results_per_page = 10 -# facet_fields = ['ano', 'tipo'] -# form_class = HackedFacetedModelSearchForm -# -# def get_context(self): -# context = super(SaplSearchView, self).get_context() -# -# if 'models' in self.request.GET: -# models = self.request.GET.getlist('models') -# else: -# models = [] -# -# context['models'] = '' -# -# for m in models: -# context['models'] = context['models'] + '&models=' + m -# -# return context - -class SaplSearchView(SearchView): +class SaplSearchView(FacetedSearchView): results_per_page = 10 + facet_fields = ['ano', 'tipo'] + form_class = HackedFacetedModelSearchForm def get_context(self): context = super(SaplSearchView, self).get_context() diff --git a/sapl/templates/search/search.html b/sapl/templates/search/search.html index d6c31da0a..f2ea61316 100644 --- a/sapl/templates/search/search.html +++ b/sapl/templates/search/search.html @@ -33,16 +33,44 @@ {% if query %} + +
Sem facet de ano.
+ {% endif %} +Sem facet de tipo.
+ {% endif %} +Resultados - Foram encontrados {{ page.paginator.count }} registros | Resultados - Foram encontrados {{ page_obj.paginator.count }} registros |
{% if result.object|search_get_model == 'm' %} @@ -91,15 +119,15 @@ {% endfor %} |