Browse Source

Correcao de bugs de pesquisa em sistemas (tabelas auxiliares) (#3511)

pull/3517/head
Gustavo274 3 years ago
committed by GitHub
parent
commit
45bb9578cb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      sapl/materia/views.py
  2. 24
      sapl/norma/views.py
  3. 46
      sapl/parlamentares/views.py

24
sapl/materia/views.py

@ -394,7 +394,7 @@ class StatusTramitacaoCrud(CrudAux):
class PesquisarStatusTramitacaoView(FilterView): class PesquisarStatusTramitacaoView(FilterView):
model = StatusTramitacao model = StatusTramitacao
filterset_class = StatusTramitacaoFilterSet filterset_class = StatusTramitacaoFilterSet
paginate_by = 10 paginate_by = 20
def get_filterset_kwargs(self, filterset_class): def get_filterset_kwargs(self, filterset_class):
super(PesquisarStatusTramitacaoView, self).get_filterset_kwargs( super(PesquisarStatusTramitacaoView, self).get_filterset_kwargs(
@ -434,17 +434,21 @@ class PesquisarStatusTramitacaoView(FilterView):
if data: if data:
url = '&' + str(self.request.META["QUERY_STRING"]) url = '&' + str(self.request.META["QUERY_STRING"])
if url.startswith("&page"): if url.startswith("&page"):
ponto_comeco = url.find("descricao=") - 1 url = ''
url = url[ponto_comeco:]
context = self.get_context_data( if 'descricao' in self.request.META['QUERY_STRING'] or\
filter=self.filterset, object_list=self.object_list, 'page' in self.request.META['QUERY_STRING']: resultados = self.object_list
filter_url=url, numero_res=len(self.object_list) else:
) resultados = []
context["show_results"] = show_results_filter_set( context = self.get_context_data(filter=self.filterset,
self.request.GET.copy() object_list=resultados,
) filter_url=url,
numero_res=len(resultados)
)
context['show_results'] = show_results_filter_set(
self.request.GET.copy())
return self.render_to_response(context) return self.render_to_response(context)

24
sapl/norma/views.py

@ -60,7 +60,7 @@ class AssuntoNormaCrud(CrudAux):
class PesquisarAssuntoNormaView(FilterView): class PesquisarAssuntoNormaView(FilterView):
model = AssuntoNorma model = AssuntoNorma
filterset_class = AssuntoNormaFilterSet filterset_class = AssuntoNormaFilterSet
paginate_by = 10 paginate_by = 20
def get_filterset_kwargs(self, filterset_class): def get_filterset_kwargs(self, filterset_class):
super(PesquisarAssuntoNormaView, self).get_filterset_kwargs( super(PesquisarAssuntoNormaView, self).get_filterset_kwargs(
@ -100,17 +100,21 @@ class PesquisarAssuntoNormaView(FilterView):
if data: if data:
url = '&' + str(self.request.META["QUERY_STRING"]) url = '&' + str(self.request.META["QUERY_STRING"])
if url.startswith("&page"): if url.startswith("&page"):
ponto_comeco = url.find("assunto=") - 1 url = ''
url = url[ponto_comeco:]
context = self.get_context_data( if 'assunto' in self.request.META['QUERY_STRING'] or\
filter=self.filterset, object_list=self.object_list, 'page' in self.request.META['QUERY_STRING']: resultados = self.object_list
filter_url=url, numero_res=len(self.object_list) else:
) resultados = []
context["show_results"] = show_results_filter_set( context = self.get_context_data(filter=self.filterset,
self.request.GET.copy() object_list=resultados,
) filter_url=url,
numero_res=len(resultados)
)
context['show_results'] = show_results_filter_set(
self.request.GET.copy())
return self.render_to_response(context) return self.render_to_response(context)

46
sapl/parlamentares/views.py

@ -183,7 +183,7 @@ class ProposicaoParlamentarCrud(CrudBaseForListAndDetailExternalAppView):
class PesquisarParlamentarView(FilterView): class PesquisarParlamentarView(FilterView):
model = Parlamentar model = Parlamentar
filterset_class = ParlamentarFilterSet filterset_class = ParlamentarFilterSet
paginate_by = 10 paginate_by = 20
def get_filterset_kwargs(self, filterset_class): def get_filterset_kwargs(self, filterset_class):
super(PesquisarParlamentarView, super(PesquisarParlamentarView,
@ -222,13 +222,17 @@ class PesquisarParlamentarView(FilterView):
if data: if data:
url = "&" + str(self.request.META['QUERY_STRING']) url = "&" + str(self.request.META['QUERY_STRING'])
if url.startswith("&page"): if url.startswith("&page"):
ponto_comeco = url.find('nome_parlamentar=') - 1 url = ''
url = url[ponto_comeco:]
if 'nome_parlamentar' in self.request.META['QUERY_STRING'] or\
'page' in self.request.META['QUERY_STRING']: resultados = self.object_list
else:
resultados = []
context = self.get_context_data(filter=self.filterset, context = self.get_context_data(filter=self.filterset,
object_list=self.object_list, object_list=resultados,
filter_url=url, filter_url=url,
numero_res=len(self.object_list) numero_res=len(resultados)
) )
context['show_results'] = show_results_filter_set( context['show_results'] = show_results_filter_set(
@ -240,7 +244,7 @@ class PesquisarParlamentarView(FilterView):
class PesquisarColigacaoView(FilterView): class PesquisarColigacaoView(FilterView):
model = Coligacao model = Coligacao
filterset_class = ColigacaoFilterSet filterset_class = ColigacaoFilterSet
paginate_by = 10 paginate_by = 20
def get_filterset_kwargs(self, filterset_class): def get_filterset_kwargs(self, filterset_class):
super(PesquisarColigacaoView, self).get_filterset_kwargs(filterset_class) super(PesquisarColigacaoView, self).get_filterset_kwargs(filterset_class)
@ -273,13 +277,18 @@ class PesquisarColigacaoView(FilterView):
if data: if data:
url = "&" + str(self.request.META['QUERY_STRING']) url = "&" + str(self.request.META['QUERY_STRING'])
if url.startswith("&page"): if url.startswith("&page"):
ponto_comeco = url.find('nome=') - 1 url = ''
url = url[ponto_comeco:]
if 'nome' in self.request.META['QUERY_STRING'] or\
'page' in self.request.META['QUERY_STRING']: resultados = self.object_list
else:
resultados = []
context = self.get_context_data(filter=self.filterset, context = self.get_context_data(filter=self.filterset,
object_list=self.object_list, object_list=resultados,
filter_url=url, filter_url=url,
numero_res=len(self.object_list)) numero_res=len(resultados)
)
context['show_results'] = show_results_filter_set( context['show_results'] = show_results_filter_set(
self.request.GET.copy()) self.request.GET.copy())
@ -290,7 +299,7 @@ class PesquisarColigacaoView(FilterView):
class PesquisarPartidoView(FilterView): class PesquisarPartidoView(FilterView):
model = Partido model = Partido
filterset_class = PartidoFilterSet filterset_class = PartidoFilterSet
paginate_by = 10 paginate_by = 20
def get_filterset_kwargs(self, filterset_class): def get_filterset_kwargs(self, filterset_class):
super(PesquisarPartidoView, self).get_filterset_kwargs(filterset_class) super(PesquisarPartidoView, self).get_filterset_kwargs(filterset_class)
@ -322,19 +331,26 @@ class PesquisarPartidoView(FilterView):
if data: if data:
url = "&" + str(self.request.META['QUERY_STRING']) url = "&" + str(self.request.META['QUERY_STRING'])
if url.startswith("&page"): if url.startswith("&page"):
ponto_comeco = url.find('nome=') - 1 url = ''
url = url[ponto_comeco:]
if 'nome' in self.request.META['QUERY_STRING'] or\
'page' in self.request.META['QUERY_STRING']: resultados = self.object_list
else:
resultados = []
context = self.get_context_data(filter=self.filterset, context = self.get_context_data(filter=self.filterset,
object_list=self.object_list, object_list=resultados,
filter_url=url, filter_url=url,
numero_res=len(self.object_list)) numero_res=len(resultados)
)
context['show_results'] = show_results_filter_set( context['show_results'] = show_results_filter_set(
self.request.GET.copy()) self.request.GET.copy())
return self.render_to_response(context) return self.render_to_response(context)
class ParticipacaoParlamentarCrud(CrudBaseForListAndDetailExternalAppView): class ParticipacaoParlamentarCrud(CrudBaseForListAndDetailExternalAppView):
model = Participacao model = Participacao
parent_field = 'parlamentar' parent_field = 'parlamentar'

Loading…
Cancel
Save