diff --git a/sapl/compilacao/views.py b/sapl/compilacao/views.py index 82b5cbd10..6cf1911d6 100644 --- a/sapl/compilacao/views.py +++ b/sapl/compilacao/views.py @@ -2892,7 +2892,21 @@ class DispositivoSearchFragmentFormView(ListView): itens.append(item) return JsonResponse(itens, safe=False) - return ListView.get(self, request, *args, **kwargs) + response = ListView.get(self, request, *args, **kwargs) + + if not self.object_list.exists(): + messages.info( + request, _('Não foram encontrados resultados ' + 'com seus critérios de busca!')) + + try: + r = response.render() + return response + except Exception as e: + messages.error(request, "Erro - %s" % e) + context = {} + self.template_name = 'compilacao/messages.html' + return self.render_to_response(context) def get_queryset(self): try: diff --git a/sapl/templates/compilacao/dispositivo_form_search_fragment.html b/sapl/templates/compilacao/dispositivo_form_search_fragment.html index 95d91a2cf..2df5aa0de 100644 --- a/sapl/templates/compilacao/dispositivo_form_search_fragment.html +++ b/sapl/templates/compilacao/dispositivo_form_search_fragment.html @@ -1,5 +1,14 @@ {% load i18n compilacao_filters %} +{% for message in messages %} + +{% endfor %} + {% if object_list.count >= 100 %}
{% trans 'Use argumentos para simplificar listagem...' %} diff --git a/sapl/templates/compilacao/messages.html b/sapl/templates/compilacao/messages.html new file mode 100644 index 000000000..1777831c7 --- /dev/null +++ b/sapl/templates/compilacao/messages.html @@ -0,0 +1,10 @@ +{% load i18n compilacao_filters %} + +{% for message in messages %} + +{% endfor %} \ No newline at end of file