|
|
@ -1,6 +1,7 @@ |
|
|
import collections |
|
|
import collections |
|
|
import itertools |
|
|
|
|
|
import datetime |
|
|
import datetime |
|
|
|
|
|
import itertools |
|
|
|
|
|
import json |
|
|
import logging |
|
|
import logging |
|
|
import os |
|
|
import os |
|
|
|
|
|
|
|
|
@ -15,11 +16,13 @@ from django.core.urlresolvers import reverse, reverse_lazy |
|
|
from django.db import connection |
|
|
from django.db import connection |
|
|
from django.db.models import Count, Q, ProtectedError |
|
|
from django.db.models import Count, Q, ProtectedError |
|
|
from django.http import Http404, HttpResponseRedirect |
|
|
from django.http import Http404, HttpResponseRedirect |
|
|
|
|
|
from django.shortcuts import render |
|
|
from django.template import TemplateDoesNotExist |
|
|
from django.template import TemplateDoesNotExist |
|
|
from django.template.loader import get_template |
|
|
from django.template.loader import get_template |
|
|
from django.utils import timezone |
|
|
from django.utils import timezone |
|
|
from django.utils.encoding import force_bytes |
|
|
from django.utils.encoding import force_bytes |
|
|
from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode |
|
|
from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode |
|
|
|
|
|
from django.utils.safestring import mark_safe |
|
|
from django.utils.translation import string_concat |
|
|
from django.utils.translation import string_concat |
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
from django.views.generic import (CreateView, DeleteView, FormView, ListView, |
|
|
from django.views.generic import (CreateView, DeleteView, FormView, ListView, |
|
|
@ -61,6 +64,16 @@ from .forms import (AlterarSenhaForm, CasaLegislativaForm, |
|
|
from .models import AppConfig, CasaLegislativa |
|
|
from .models import AppConfig, CasaLegislativa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def chanel_index(request): |
|
|
|
|
|
return render(request, 'base/channel_index.html', {}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def chanel_room(request, room_name): |
|
|
|
|
|
return render(request, 'base/channel_room.html', { |
|
|
|
|
|
'room_name_json': mark_safe(json.dumps(room_name)) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def filtra_url_materias_em_tramitacao(qr, qs, campo_url, local_ou_status): |
|
|
def filtra_url_materias_em_tramitacao(qr, qs, campo_url, local_ou_status): |
|
|
id_materias = [] |
|
|
id_materias = [] |
|
|
filtro_url = qr[campo_url] |
|
|
filtro_url = qr[campo_url] |
|
|
@ -836,16 +849,17 @@ class RelatorioNormasVigenciaView(FilterView): |
|
|
|
|
|
|
|
|
if vigencia == 'True': |
|
|
if vigencia == 'True': |
|
|
qs_dt_not_null = qs.filter(data_vigencia__isnull=True) |
|
|
qs_dt_not_null = qs.filter(data_vigencia__isnull=True) |
|
|
qs = (qs_dt_not_null | qs.filter(data_vigencia__gte=datetime.datetime.now().date())).distinct() |
|
|
qs = (qs_dt_not_null | qs.filter( |
|
|
|
|
|
data_vigencia__gte=datetime.datetime.now().date())).distinct() |
|
|
else: |
|
|
else: |
|
|
qs = qs.filter(data_vigencia__lt=datetime.datetime.now().date()) |
|
|
qs = qs.filter( |
|
|
|
|
|
data_vigencia__lt=datetime.datetime.now().date()) |
|
|
|
|
|
|
|
|
kwargs.update({ |
|
|
kwargs.update({ |
|
|
'queryset': qs |
|
|
'queryset': qs |
|
|
}) |
|
|
}) |
|
|
return kwargs |
|
|
return kwargs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs): |
|
|
def get_context_data(self, **kwargs): |
|
|
context = super(RelatorioNormasVigenciaView, |
|
|
context = super(RelatorioNormasVigenciaView, |
|
|
self).get_context_data(**kwargs) |
|
|
self).get_context_data(**kwargs) |
|
|
@ -855,17 +869,20 @@ class RelatorioNormasVigenciaView(FilterView): |
|
|
if not self.filterset.form.is_valid(): |
|
|
if not self.filterset.form.is_valid(): |
|
|
return context |
|
|
return context |
|
|
|
|
|
|
|
|
normas_totais = NormaJuridica.objects.filter(ano=self.request.GET['ano']) |
|
|
normas_totais = NormaJuridica.objects.filter( |
|
|
|
|
|
ano=self.request.GET['ano']) |
|
|
|
|
|
|
|
|
context['quant_total'] = len(normas_totais) |
|
|
context['quant_total'] = len(normas_totais) |
|
|
if self.request.GET['vigencia'] == 'True': |
|
|
if self.request.GET['vigencia'] == 'True': |
|
|
context['vigencia'] = 'Vigente' |
|
|
context['vigencia'] = 'Vigente' |
|
|
context['quant_vigente'] = len(context['object_list']) |
|
|
context['quant_vigente'] = len(context['object_list']) |
|
|
context['quant_nao_vigente'] = context['quant_total'] - context['quant_vigente'] |
|
|
context['quant_nao_vigente'] = context['quant_total'] - \ |
|
|
|
|
|
context['quant_vigente'] |
|
|
else: |
|
|
else: |
|
|
context['vigencia'] = 'Não vigente' |
|
|
context['vigencia'] = 'Não vigente' |
|
|
context['quant_nao_vigente'] = len(context['object_list']) |
|
|
context['quant_nao_vigente'] = len(context['object_list']) |
|
|
context['quant_vigente'] = context['quant_total'] - context['quant_nao_vigente'] |
|
|
context['quant_vigente'] = context['quant_total'] - \ |
|
|
|
|
|
context['quant_nao_vigente'] |
|
|
|
|
|
|
|
|
qr = self.request.GET.copy() |
|
|
qr = self.request.GET.copy() |
|
|
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else '' |
|
|
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else '' |
|
|
@ -915,7 +932,8 @@ class EstatisticasAcessoNormas(TemplateView): |
|
|
|
|
|
|
|
|
# Ordena por acesso e limita em 5 |
|
|
# Ordena por acesso e limita em 5 |
|
|
for n in normas_mes: |
|
|
for n in normas_mes: |
|
|
sorted_by_value = sorted(normas_mes[n], key=lambda kv: kv[1], reverse=True) |
|
|
sorted_by_value = sorted( |
|
|
|
|
|
normas_mes[n], key=lambda kv: kv[1], reverse=True) |
|
|
normas_mes[n] = sorted_by_value[0:5] |
|
|
normas_mes[n] = sorted_by_value[0:5] |
|
|
|
|
|
|
|
|
context['normas_mes'] = normas_mes |
|
|
context['normas_mes'] = normas_mes |
|
|
@ -1097,10 +1115,12 @@ def parlamentares_mandatos_intersecao(): |
|
|
|
|
|
|
|
|
for c in combinacoes: |
|
|
for c in combinacoes: |
|
|
data_inicio_mandato1 = c[0].data_inicio_mandato |
|
|
data_inicio_mandato1 = c[0].data_inicio_mandato |
|
|
data_fim_mandato1 = c[0].data_fim_mandato if c[0].data_fim_mandato else timezone.now().date() |
|
|
data_fim_mandato1 = c[0].data_fim_mandato if c[0].data_fim_mandato else timezone.now( |
|
|
|
|
|
).date() |
|
|
|
|
|
|
|
|
data_inicio_mandato2 = c[1].data_inicio_mandato |
|
|
data_inicio_mandato2 = c[1].data_inicio_mandato |
|
|
data_fim_mandato2 = c[1].data_fim_mandato if c[1].data_fim_mandato else timezone.now().date() |
|
|
data_fim_mandato2 = c[1].data_fim_mandato if c[1].data_fim_mandato else timezone.now( |
|
|
|
|
|
).date() |
|
|
|
|
|
|
|
|
if data_inicio_mandato1 and data_inicio_mandato2: |
|
|
if data_inicio_mandato1 and data_inicio_mandato2: |
|
|
exists = intervalos_tem_intersecao( |
|
|
exists = intervalos_tem_intersecao( |
|
|
@ -1244,6 +1264,7 @@ def protocolos_duplicados(): |
|
|
|
|
|
|
|
|
return [(v[0], len(v)) for (k, v) in protocolos.items() if len(v) > 1] |
|
|
return [(v[0], len(v)) for (k, v) in protocolos.items() if len(v) > 1] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ListarProtocolosDuplicadosView(PermissionRequiredMixin, ListView): |
|
|
class ListarProtocolosDuplicadosView(PermissionRequiredMixin, ListView): |
|
|
model = get_user_model() |
|
|
model = get_user_model() |
|
|
template_name = 'base/protocolos_duplicados.html' |
|
|
template_name = 'base/protocolos_duplicados.html' |
|
|
|