Browse Source

add msg info em busca de dispositivos e msg de erro

pull/2322/head
Leandro Roberto 6 years ago
parent
commit
df770218bb
  1. 16
      sapl/compilacao/views.py
  2. 9
      sapl/templates/compilacao/dispositivo_form_search_fragment.html
  3. 10
      sapl/templates/compilacao/messages.html

16
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:

9
sapl/templates/compilacao/dispositivo_form_search_fragment.html

@ -1,5 +1,14 @@
{% load i18n compilacao_filters %}
{% for message in messages %}
<div class="alert alert-{% if message.tags == 'error' %}danger{% else %}{{ message.tags }}{% endif %} alert-dismissible fade in" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</button>
{{ message|safe }}
</div>
{% endfor %}
{% if object_list.count >= 100 %}
<div class="alert-box success radius">
{% trans 'Use argumentos para simplificar listagem...' %}

10
sapl/templates/compilacao/messages.html

@ -0,0 +1,10 @@
{% load i18n compilacao_filters %}
{% for message in messages %}
<div class="alert alert-{% if message.tags == 'error' %}danger{% else %}{{ message.tags }}{% endif %} alert-dismissible fade in" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</button>
{{ message|safe }}
</div>
{% endfor %}
Loading…
Cancel
Save