|
@ -1,16 +1,35 @@ |
|
|
from datetime import datetime |
|
|
from datetime import datetime, date |
|
|
from random import choice |
|
|
from random import choice |
|
|
from string import ascii_letters, digits |
|
|
from string import ascii_letters, digits |
|
|
|
|
|
|
|
|
|
|
|
from .email_utils import do_envia_email_confirmacao |
|
|
|
|
|
from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm, |
|
|
|
|
|
AdicionarVariasAutoriasFilterSet, DespachoInicialForm, |
|
|
|
|
|
DocumentoAcessorioForm, MateriaAssuntoForm, |
|
|
|
|
|
MateriaLegislativaFilterSet, MateriaSimplificadaForm, |
|
|
|
|
|
PrimeiraTramitacaoEmLoteFilterSet, ReceberProposicaoForm, |
|
|
|
|
|
RelatoriaForm, TramitacaoEmLoteFilterSet, |
|
|
|
|
|
filtra_tramitacao_destino, |
|
|
|
|
|
filtra_tramitacao_destino_and_status, |
|
|
|
|
|
filtra_tramitacao_status) |
|
|
|
|
|
from .models import (AcompanhamentoMateria, Anexada, AssuntoMateria, Autoria, |
|
|
|
|
|
DespachoInicial, DocumentoAcessorio, MateriaAssunto, |
|
|
|
|
|
MateriaLegislativa, Numeracao, Orgao, Origem, Proposicao, |
|
|
|
|
|
RegimeTramitacao, Relatoria, StatusTramitacao, |
|
|
|
|
|
TipoDocumento, TipoFimRelatoria, TipoMateriaLegislativa, |
|
|
|
|
|
TipoProposicao, Tramitacao, UnidadeTramitacao) |
|
|
|
|
|
from .signals import tramitacao_signal |
|
|
from crispy_forms.helper import FormHelper |
|
|
from crispy_forms.helper import FormHelper |
|
|
from crispy_forms.layout import HTML |
|
|
from crispy_forms.layout import HTML |
|
|
from django import forms |
|
|
from django import forms |
|
|
from django.contrib import messages |
|
|
from django.contrib import messages |
|
|
from django.contrib.auth.decorators import permission_required |
|
|
from django.contrib.auth.decorators import permission_required |
|
|
from django.contrib.auth.mixins import PermissionRequiredMixin |
|
|
from django.contrib.auth.mixins import PermissionRequiredMixin |
|
|
|
|
|
from django.contrib.contenttypes.models import ContentType |
|
|
from django.core.exceptions import (ObjectDoesNotExist, |
|
|
from django.core.exceptions import (ObjectDoesNotExist, |
|
|
MultipleObjectsReturned) |
|
|
MultipleObjectsReturned) |
|
|
from django.core.urlresolvers import reverse |
|
|
from django.core.urlresolvers import reverse |
|
|
|
|
|
from django.db.models import Q |
|
|
from django.http import HttpResponse, JsonResponse |
|
|
from django.http import HttpResponse, JsonResponse |
|
|
from django.http.response import Http404, HttpResponseRedirect |
|
|
from django.http.response import Http404, HttpResponseRedirect |
|
|
from django.shortcuts import get_object_or_404, redirect |
|
|
from django.shortcuts import get_object_or_404, redirect |
|
@ -20,8 +39,9 @@ from django.views.generic import CreateView, ListView, TemplateView, UpdateView |
|
|
from django.views.generic.base import RedirectView |
|
|
from django.views.generic.base import RedirectView |
|
|
from django.views.generic.edit import FormView |
|
|
from django.views.generic.edit import FormView |
|
|
from django_filters.views import FilterView |
|
|
from django_filters.views import FilterView |
|
|
|
|
|
import sapl |
|
|
from sapl.base.models import Autor, CasaLegislativa |
|
|
from sapl.base.models import Autor, CasaLegislativa |
|
|
|
|
|
from sapl.comissoes.models import Comissao |
|
|
from sapl.comissoes.models import Comissao, Participacao |
|
|
from sapl.comissoes.models import Comissao, Participacao |
|
|
from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_RESTRICT, |
|
|
from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_RESTRICT, |
|
|
STATUS_TA_PRIVATE) |
|
|
STATUS_TA_PRIVATE) |
|
@ -32,35 +52,17 @@ from sapl.crud.base import (ACTION_CREATE, ACTION_DELETE, ACTION_DETAIL, |
|
|
Crud, CrudAux, MasterDetailCrud, |
|
|
Crud, CrudAux, MasterDetailCrud, |
|
|
PermissionRequiredForAppCrudMixin, make_pagination) |
|
|
PermissionRequiredForAppCrudMixin, make_pagination) |
|
|
from sapl.materia.forms import (AnexadaForm, ConfirmarProposicaoForm, |
|
|
from sapl.materia.forms import (AnexadaForm, ConfirmarProposicaoForm, |
|
|
LegislacaoCitadaForm, ProposicaoForm, |
|
|
LegislacaoCitadaForm, AutoriaForm, ProposicaoForm, |
|
|
TipoProposicaoForm, TramitacaoForm, |
|
|
TipoProposicaoForm, TramitacaoForm, |
|
|
TramitacaoUpdateForm) |
|
|
TramitacaoUpdateForm) |
|
|
|
|
|
from sapl.materia.models import Autor |
|
|
from sapl.norma.models import LegislacaoCitada |
|
|
from sapl.norma.models import LegislacaoCitada |
|
|
|
|
|
from sapl.parlamentares.models import Parlamentar |
|
|
from sapl.protocoloadm.models import Protocolo |
|
|
from sapl.protocoloadm.models import Protocolo |
|
|
from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label, |
|
|
from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label, |
|
|
autor_modal, gerar_hash_arquivo, get_base_url, |
|
|
autor_modal, gerar_hash_arquivo, get_base_url, |
|
|
montar_row_autor) |
|
|
montar_row_autor) |
|
|
import sapl |
|
|
|
|
|
|
|
|
|
|
|
from .email_utils import do_envia_email_confirmacao |
|
|
|
|
|
|
|
|
|
|
|
from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm, |
|
|
|
|
|
AdicionarVariasAutoriasFilterSet, DespachoInicialForm, |
|
|
|
|
|
DocumentoAcessorioForm, MateriaAssuntoForm, |
|
|
|
|
|
MateriaLegislativaFilterSet, MateriaSimplificadaForm, |
|
|
|
|
|
PrimeiraTramitacaoEmLoteFilterSet, ReceberProposicaoForm, |
|
|
|
|
|
RelatoriaForm, TramitacaoEmLoteFilterSet, |
|
|
|
|
|
filtra_tramitacao_destino, |
|
|
|
|
|
filtra_tramitacao_destino_and_status, |
|
|
|
|
|
filtra_tramitacao_status) |
|
|
|
|
|
from .models import (AcompanhamentoMateria, Anexada, AssuntoMateria, Autoria, |
|
|
|
|
|
DespachoInicial, DocumentoAcessorio, MateriaAssunto, |
|
|
|
|
|
MateriaLegislativa, Numeracao, Orgao, Origem, Proposicao, |
|
|
|
|
|
RegimeTramitacao, Relatoria, StatusTramitacao, |
|
|
|
|
|
TipoDocumento, TipoFimRelatoria, TipoMateriaLegislativa, |
|
|
|
|
|
TipoProposicao, Tramitacao, UnidadeTramitacao) |
|
|
|
|
|
|
|
|
|
|
|
from .signals import tramitacao_signal |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AssuntoMateriaCrud = Crud.build(AssuntoMateria, 'assunto_materia') |
|
|
AssuntoMateriaCrud = Crud.build(AssuntoMateria, 'assunto_materia') |
|
@ -1072,6 +1074,32 @@ class AutoriaCrud(MasterDetailCrud): |
|
|
help_path = '' |
|
|
help_path = '' |
|
|
public = [RP_LIST, RP_DETAIL] |
|
|
public = [RP_LIST, RP_DETAIL] |
|
|
|
|
|
|
|
|
|
|
|
class CreateView(MasterDetailCrud.CreateView): |
|
|
|
|
|
form_class = AutoriaForm |
|
|
|
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs): |
|
|
|
|
|
context = super(CreateView, self).get_context_data(**kwargs) |
|
|
|
|
|
autores_ativos = self.autores_ativos() |
|
|
|
|
|
|
|
|
|
|
|
autores = [] |
|
|
|
|
|
for a in autores_ativos: |
|
|
|
|
|
autores.append([a.id, a.__str__()]) |
|
|
|
|
|
|
|
|
|
|
|
context['form'].fields['autor'].choices = autores |
|
|
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
def autores_ativos(self): |
|
|
|
|
|
lista_parlamentares = Parlamentar.objects.filter(ativo=True).values_list('id', flat=True) |
|
|
|
|
|
model_parlamentar = ContentType.objects.get_for_model(Parlamentar) |
|
|
|
|
|
autor_parlamentar = Autor.objects.filter(content_type=model_parlamentar, object_id__in=lista_parlamentares) |
|
|
|
|
|
|
|
|
|
|
|
lista_comissoes = Comissao.objects.filter(Q(data_extincao__isnull=True)|Q(data_extincao__gt=date.today())).values_list('id', flat=True) |
|
|
|
|
|
model_comissao = ContentType.objects.get_for_model(Comissao) |
|
|
|
|
|
autor_comissoes = Autor.objects.filter(content_type=model_comissao, object_id__in=lista_comissoes) |
|
|
|
|
|
autores_outros = Autor.objects.exclude(content_type__in=[model_parlamentar, model_comissao]) |
|
|
|
|
|
q = autor_parlamentar | autor_comissoes | autores_outros |
|
|
|
|
|
return q |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DespachoInicialCrud(MasterDetailCrud): |
|
|
class DespachoInicialCrud(MasterDetailCrud): |
|
|
model = DespachoInicial |
|
|
model = DespachoInicial |
|
|