Browse Source

Adiciona endpoint para vereficar se SAPL alimentado

pull/2600/head
Edward Ribeiro 6 years ago
parent
commit
c1e6595ae6
  1. 4
      sapl/base/urls.py
  2. 22
      sapl/base/views.py

4
sapl/base/urls.py

@ -8,7 +8,7 @@ from django.contrib.auth.views import (password_reset, password_reset_complete,
password_reset_done)
from django.views.generic.base import RedirectView, TemplateView
from sapl.base.views import AutorCrud, ConfirmarEmailView, TipoAutorCrud
from sapl.base.views import AutorCrud, ConfirmarEmailView, TipoAutorCrud, get_data_ultima_atualizacao
from sapl.settings import EMAIL_SEND_USER, MEDIA_URL
from .apps import AppConfig
@ -176,6 +176,8 @@ urlpatterns = [
ListarLegislaturaInfindavelView.as_view(),
name='lista_legislatura_infindavel'),
url(r'^sistema/data_ultima_atualizacao', get_data_ultima_atualizacao),
# todos os sublinks de sistema devem vir acima deste
url(r'^sistema/$', permission_required('base.view_tabelas_auxiliares')
(TemplateView.as_view(template_name='sistema.html')),

22
sapl/base/views.py

@ -14,7 +14,7 @@ from django.core.mail import send_mail
from django.core.urlresolvers import reverse, reverse_lazy
from django.db import connection
from django.db.models import Count, Q, ProtectedError
from django.http import Http404, HttpResponseRedirect
from django.http import Http404, HttpResponseRedirect, JsonResponse
from django.template import TemplateDoesNotExist
from django.template.loader import get_template
from django.utils import timezone
@ -1234,6 +1234,26 @@ def mandato_sem_data_inicio():
return Mandato.objects.filter(data_inicio_mandato__isnull=True).order_by('parlamentar')
def get_data_ultima_atualizacao(request):
datas = [MateriaLegislativa.objects.all().
order_by('-data_ultima_atualizacao').
values_list('data_ultima_atualizacao', flat=True).
first(),
NormaJuridica.objects.all().
order_by('-data_ultima_atualizacao').
values_list('data_ultima_atualizacao', flat=True).
first()]
max_data = ''
if datas[0] and datas[1]:
max_data = max(datas)
else:
max_data = next([i for i in datas if i is not None], '')
return JsonResponse({'data_ultima_atualizacao': max_data})
class ListarMandatoSemDataInicioView(PermissionRequiredMixin, ListView):
model = get_user_model()
template_name = 'base/mandato_sem_data_inicio.html'

Loading…
Cancel
Save