Browse Source

Fix #179

Move formulários para um arquivo forms.py
pull/202/head
Edward Ribeiro 9 years ago
parent
commit
bf6cde8395
  1. 146
      base/forms.py
  2. 146
      base/views.py
  3. 173
      comissoes/forms.py
  4. 171
      comissoes/views.py
  5. 741
      materia/forms.py
  6. 837
      materia/views.py
  7. 102
      norma/forms.py
  8. 99
      norma/views.py
  9. 324
      parlamentares/forms.py
  10. 325
      parlamentares/views.py
  11. 410
      protocoloadm/forms.py
  12. 405
      protocoloadm/views.py
  13. 2
      relatorios/views.py
  14. 159
      sessao/forms.py
  15. 167
      sessao/views.py

146
base/forms.py

@ -0,0 +1,146 @@
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Fieldset, Layout
from django import forms
from django.forms import ModelForm
import sapl
from sapl.layout import form_actions
from .models import CasaLegislativa
ESTADOS = {"": "",
"AC": "ACRE",
"AL": "ALAGOAS",
"AM": "AMAZONAS",
"AP": "AMAPÁ",
"BA": "BAHIA",
"CE": "CEARÁ",
"DF": "DISTRITO FEDERAL",
"ES": "ESPíRITO SANTO",
"GO": "GOIÁS",
"MA": "MARANHÃO",
"MG": "MINAS GERAIS",
"MS": "MATO GROSSO DO SUL",
"MT": "MATO GROSSO",
"PA": "PARÁ",
"PB": "PARAÍBA",
"PE": "PERNAMBUCO",
"PI": "PIAUÍ",
"PR": "PARANÁ",
"RJ": "RIO DE JANEIRO",
"RN": "RIO GRANDE DO NORTE",
"RO": "RONDÔNIA",
"RR": "RORAIMA",
"RS": "RIO GRANDE DO SUL",
"SC": "SANTA CATARINA",
"SE": "SERGIPE",
"SP": "SÃO PAULO",
"TO": "TOCANTINS"}
class CasaLegislativaTabelaAuxForm(ModelForm):
uf = forms.ChoiceField(required=True,
label='UF',
choices=[(uf, uf) for uf in ESTADOS.keys()],
widget=forms.Select(
attrs={'class': 'selector'}))
informacao_geral = forms.CharField(widget=forms.Textarea,
label='Informação Geral',
required=False)
telefone = forms.CharField(label='Telefone',
required=False,
widget=forms.TextInput(
attrs={'class': 'telefone'}))
logotipo = forms.ImageField(label='Logotipo',
required=False,
widget=forms.FileInput
)
cep = forms.CharField(label='Cep',
required=True,
widget=forms.TextInput(
attrs={'class': 'cep'}))
fax = forms.CharField(label='Fax',
required=False,
widget=forms.TextInput(
attrs={'class': 'telefone'}))
class Meta:
model = CasaLegislativa
fields = ['codigo',
'nome',
'sigla',
'endereco',
'cep',
'municipio',
'uf',
'telefone',
'fax',
'logotipo',
'endereco_web',
'email',
'informacao_geral']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('codigo', 2),
('nome', 5),
('sigla', 5)])
row2 = sapl.layout.to_row(
[('endereco', 8),
('cep', 4)])
row3 = sapl.layout.to_row(
[('municipio', 10),
('uf', 2)])
row4 = sapl.layout.to_row(
[('telefone', 6),
('fax', 6)])
row5 = sapl.layout.to_row(
[('logotipo', 12)])
row6 = sapl.layout.to_row(
[('endereco_web', 12)])
row7 = sapl.layout.to_row(
[('email', 12)])
row8 = sapl.layout.to_row(
[('informacao_geral', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Dados Básicos',
row1,
row2,
row3,
row4,
row5,
HTML("""{% if form.logotipo.value %}
<img class="img-responsive" width="225" height="300"
src="{{ MEDIA_URL }}{{ form.logotipo.value }}">
<br /><br />
<input type="submit"
name="remover"
id="remover"
class="button primary"
value="Remover Logo"/>
{% endif %}""", ),
row6,
row7,
row8,
form_actions()
)
)
super(CasaLegislativaTabelaAuxForm, self).__init__(*args, **kwargs)

146
base/views.py

@ -1,19 +1,13 @@
import os import os
from functools import lru_cache from functools import lru_cache
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Fieldset, Layout
from django import forms
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.forms import ModelForm
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from vanilla import GenericView from vanilla import GenericView
import sapl from .forms import CasaLegislativaTabelaAuxForm
from sapl.layout import form_actions
from .models import CasaLegislativa from .models import CasaLegislativa
@ -29,144 +23,6 @@ class HelpView(TemplateView):
return ['ajuda/%s.html' % self.kwargs['topic']] return ['ajuda/%s.html' % self.kwargs['topic']]
ESTADOS = {"": "",
"AC": "ACRE",
"AL": "ALAGOAS",
"AM": "AMAZONAS",
"AP": "AMAPÁ",
"BA": "BAHIA",
"CE": "CEARÁ",
"DF": "DISTRITO FEDERAL",
"ES": "ESPíRITO SANTO",
"GO": "GOIÁS",
"MA": "MARANHÃO",
"MG": "MINAS GERAIS",
"MS": "MATO GROSSO DO SUL",
"MT": "MATO GROSSO",
"PA": "PARÁ",
"PB": "PARAÍBA",
"PE": "PERNAMBUCO",
"PI": "PIAUÍ",
"PR": "PARANÁ",
"RJ": "RIO DE JANEIRO",
"RN": "RIO GRANDE DO NORTE",
"RO": "RONDÔNIA",
"RR": "RORAIMA",
"RS": "RIO GRANDE DO SUL",
"SC": "SANTA CATARINA",
"SE": "SERGIPE",
"SP": "SÃO PAULO",
"TO": "TOCANTINS"}
class CasaLegislativaTabelaAuxForm(ModelForm):
uf = forms.ChoiceField(required=True,
label='UF',
choices=[(uf, uf) for uf in ESTADOS.keys()],
widget=forms.Select(
attrs={'class': 'selector'}))
informacao_geral = forms.CharField(widget=forms.Textarea,
label='Informação Geral',
required=False)
telefone = forms.CharField(label='Telefone',
required=False,
widget=forms.TextInput(
attrs={'class': 'telefone'}))
logotipo = forms.ImageField(label='Logotipo',
required=False,
widget=forms.FileInput
)
cep = forms.CharField(label='Cep',
required=True,
widget=forms.TextInput(
attrs={'class': 'cep'}))
fax = forms.CharField(label='Fax',
required=False,
widget=forms.TextInput(
attrs={'class': 'telefone'}))
class Meta:
model = CasaLegislativa
fields = ['codigo',
'nome',
'sigla',
'endereco',
'cep',
'municipio',
'uf',
'telefone',
'fax',
'logotipo',
'endereco_web',
'email',
'informacao_geral']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('codigo', 2),
('nome', 5),
('sigla', 5)])
row2 = sapl.layout.to_row(
[('endereco', 8),
('cep', 4)])
row3 = sapl.layout.to_row(
[('municipio', 10),
('uf', 2)])
row4 = sapl.layout.to_row(
[('telefone', 6),
('fax', 6)])
row5 = sapl.layout.to_row(
[('logotipo', 12)])
row6 = sapl.layout.to_row(
[('endereco_web', 12)])
row7 = sapl.layout.to_row(
[('email', 12)])
row8 = sapl.layout.to_row(
[('informacao_geral', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Dados Básicos',
row1,
row2,
row3,
row4,
row5,
HTML("""{% if form.logotipo.value %}
<img class="img-responsive" width="225" height="300"
src="{{ MEDIA_URL }}{{ form.logotipo.value }}">
<br /><br />
<input type="submit"
name="remover"
id="remover"
class="button primary"
value="Remover Logo"/>
{% endif %}""", ),
row6,
row7,
row8,
form_actions()
)
)
super(CasaLegislativaTabelaAuxForm, self).__init__(*args, **kwargs)
class CasaLegislativaTableAuxView(FormMixin, GenericView): class CasaLegislativaTableAuxView(FormMixin, GenericView):
template_name = "base/casa_leg_table_aux.html" template_name = "base/casa_leg_table_aux.html"

173
comissoes/forms.py

@ -0,0 +1,173 @@
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Fieldset, Layout
from django import forms
from django.forms import ModelForm
import sapl
from parlamentares.models import Filiacao
from sapl.layout import form_actions
from .models import Comissao, Participacao
class CadastrarComissaoForm(ModelForm):
class Meta:
model = Comissao
fields = ['nome',
'tipo',
'sigla',
'data_criacao',
'data_extincao',
'unidade_deliberativa',
'local_reuniao',
'agenda_reuniao',
'telefone_reuniao',
'endereco_secretaria',
'telefone_secretaria',
'fax_secretaria',
'secretario',
'email',
'finalidade',
'apelido_temp',
'data_instalacao_temp',
'data_final_prevista_temp',
'data_prorrogada_temp',
'data_fim_comissao']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('nome', 8),
('sigla', 4)])
row2 = sapl.layout.to_row(
[('tipo', 3),
('data_criacao', 3),
('unidade_deliberativa', 3),
('data_extincao', 3)])
row3 = sapl.layout.to_row(
[('local_reuniao', 4),
('agenda_reuniao', 4),
('telefone_reuniao', 4)])
row4 = sapl.layout.to_row(
[('endereco_secretaria', 4),
('telefone_secretaria', 4),
('fax_secretaria', 4)])
row5 = sapl.layout.to_row(
[('secretario', 6),
('email', 6)])
row6 = sapl.layout.to_row(
[('finalidade', 12)])
row7 = sapl.layout.to_row(
[('apelido_temp', 9),
('data_instalacao_temp', 3)])
row8 = sapl.layout.to_row(
[('data_final_prevista_temp', 4),
('data_prorrogada_temp', 4),
('data_fim_comissao', 4)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Cadastrar Comissão',
Fieldset(
'Dados Básicos',
row1,
row2
),
Fieldset(
'Dados Complementares',
row3,
row4,
row5,
row6
),
Fieldset(
'Temporária',
row7,
row8
),
form_actions()
)
)
super(CadastrarComissaoForm, self).__init__(*args, **kwargs)
class ComposicaoForm(forms.Form):
periodo = forms.CharField()
class ParticipacaoCadastroForm(ModelForm):
YES_OR_NO = (
(True, 'Sim'),
(False, 'Não')
)
parlamentar_id = forms.ModelChoiceField(
label='Parlamentar',
required=True,
queryset=Filiacao.objects.filter(
data_desfiliacao__isnull=True, parlamentar__ativo=True).order_by(
'parlamentar__nome_parlamentar'),
empty_label='Selecione',
)
data_designacao = forms.DateField(label=u'Data Designação',
input_formats=['%d/%m/%Y'],
required=True,
widget=forms.DateInput(
format='%d/%m/%Y'))
data_desligamento = forms.DateField(label=u'Data Desligamento',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y'))
class Meta:
model = Participacao
fields = ['parlamentar_id',
'cargo',
'titular',
'data_designacao',
'data_desligamento',
'motivo_desligamento',
'observacao']
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
row1 = sapl.layout.to_row(
[('parlamentar_id', 4),
('cargo', 4),
('titular', 4)])
row2 = sapl.layout.to_row(
[('data_designacao', 6),
('data_desligamento', 6)])
row3 = sapl.layout.to_row(
[('motivo_desligamento', 12)])
row4 = sapl.layout.to_row(
[('observacao', 12)])
self.helper.layout = Layout(
Fieldset(
'Formulário de Cadastro',
row1, row2, row3, row4
),
form_actions()
)
super(ParticipacaoCadastroForm, self).__init__(*args, **kwargs)

171
comissoes/views.py

@ -1,20 +1,16 @@
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Fieldset, Layout
from django import forms
from django.contrib import messages from django.contrib import messages
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import ListView from django.views.generic import ListView
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from vanilla import GenericView from vanilla import GenericView
import sapl
from materia.models import Tramitacao from materia.models import Tramitacao
from parlamentares.models import Filiacao from parlamentares.models import Filiacao
from sapl.crud import build_crud from sapl.crud import build_crud
from sapl.layout import form_actions
from .forms import (CadastrarComissaoForm, ComposicaoForm,
ParticipacaoCadastroForm)
from .models import (CargoComissao, Comissao, Composicao, Participacao, from .models import (CargoComissao, Comissao, Composicao, Participacao,
Periodo, TipoComissao) Periodo, TipoComissao)
@ -68,99 +64,6 @@ comissao_crud = build_crud(
]) ])
class CadastrarComissaoForm(ModelForm):
class Meta:
model = Comissao
fields = ['nome',
'tipo',
'sigla',
'data_criacao',
'data_extincao',
'unidade_deliberativa',
'local_reuniao',
'agenda_reuniao',
'telefone_reuniao',
'endereco_secretaria',
'telefone_secretaria',
'fax_secretaria',
'secretario',
'email',
'finalidade',
'apelido_temp',
'data_instalacao_temp',
'data_final_prevista_temp',
'data_prorrogada_temp',
'data_fim_comissao']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('nome', 8),
('sigla', 4)])
row2 = sapl.layout.to_row(
[('tipo', 3),
('data_criacao', 3),
('unidade_deliberativa', 3),
('data_extincao', 3)])
row3 = sapl.layout.to_row(
[('local_reuniao', 4),
('agenda_reuniao', 4),
('telefone_reuniao', 4)])
row4 = sapl.layout.to_row(
[('endereco_secretaria', 4),
('telefone_secretaria', 4),
('fax_secretaria', 4)])
row5 = sapl.layout.to_row(
[('secretario', 6),
('email', 6)])
row6 = sapl.layout.to_row(
[('finalidade', 12)])
row7 = sapl.layout.to_row(
[('apelido_temp', 9),
('data_instalacao_temp', 3)])
row8 = sapl.layout.to_row(
[('data_final_prevista_temp', 4),
('data_prorrogada_temp', 4),
('data_fim_comissao', 4)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Cadastrar Comissão',
Fieldset(
'Dados Básicos',
row1,
row2
),
Fieldset(
'Dados Complementares',
row3,
row4,
row5,
row6
),
Fieldset(
'Temporária',
row7,
row8
),
form_actions()
)
)
super(CadastrarComissaoForm, self).__init__(*args, **kwargs)
class CadastrarComissaoView(FormMixin, GenericView): class CadastrarComissaoView(FormMixin, GenericView):
template_name = "comissoes/cadastrar_comissao.html" template_name = "comissoes/cadastrar_comissao.html"
@ -185,10 +88,6 @@ class CadastrarComissaoView(FormMixin, GenericView):
return reverse('comissao:list') return reverse('comissao:list')
class ComposicaoForm(forms.Form):
periodo = forms.CharField()
class ComposicaoView(FormMixin, GenericView): class ComposicaoView(FormMixin, GenericView):
template_name = 'comissoes/composicao.html' template_name = 'comissoes/composicao.html'
@ -239,72 +138,6 @@ class ReunioesView(comissao_crud.CrudDetailView):
template_name = 'comissoes/reunioes.html' template_name = 'comissoes/reunioes.html'
class ParticipacaoCadastroForm(ModelForm):
YES_OR_NO = (
(True, 'Sim'),
(False, 'Não')
)
parlamentar_id = forms.ModelChoiceField(
label='Parlamentar',
required=True,
queryset=Filiacao.objects.filter(
data_desfiliacao__isnull=True, parlamentar__ativo=True).order_by(
'parlamentar__nome_parlamentar'),
empty_label='Selecione',
)
data_designacao = forms.DateField(label=u'Data Designação',
input_formats=['%d/%m/%Y'],
required=True,
widget=forms.DateInput(
format='%d/%m/%Y'))
data_desligamento = forms.DateField(label=u'Data Desligamento',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y'))
class Meta:
model = Participacao
fields = ['parlamentar_id',
'cargo',
'titular',
'data_designacao',
'data_desligamento',
'motivo_desligamento',
'observacao']
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
row1 = sapl.layout.to_row(
[('parlamentar_id', 4),
('cargo', 4),
('titular', 4)])
row2 = sapl.layout.to_row(
[('data_designacao', 6),
('data_desligamento', 6)])
row3 = sapl.layout.to_row(
[('motivo_desligamento', 12)])
row4 = sapl.layout.to_row(
[('observacao', 12)])
self.helper.layout = Layout(
Fieldset(
'Formulário de Cadastro',
row1, row2, row3, row4
),
form_actions()
)
super(ParticipacaoCadastroForm, self).__init__(*args, **kwargs)
class ComissaoParlamentarIncluirView(FormMixin, GenericView): class ComissaoParlamentarIncluirView(FormMixin, GenericView):
template_name = "comissoes/comissao_parlamentar.html" template_name = "comissoes/comissao_parlamentar.html"

741
materia/forms.py

@ -0,0 +1,741 @@
from datetime import date
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Column, Fieldset, Layout
from django import forms
from django.forms import ModelForm
from django.utils.safestring import mark_safe
import sapl
from norma.models import LegislacaoCitada, TipoNormaJuridica
from parlamentares.models import Parlamentar, Partido
from sapl.layout import form_actions
from .models import (Anexada, Autor, DespachoInicial, DocumentoAcessorio,
MateriaLegislativa, Numeracao, Origem, Proposicao,
Relatoria, StatusTramitacao, TipoAutor, TipoDocumento,
TipoMateriaLegislativa, Tramitacao, UnidadeTramitacao)
def get_range_anos():
return [('', 'Selecione')] \
+ [(year, year) for year in range(date.today().year, 1960, -1)]
def get_regimes_tramitacao():
return [('1', 'Normal'),
('3', 'Urgência'),
('4', 'Urgência Especial')]
def get_local_origem():
return [('E', 'Poder Executivo'),
('L', 'Poder Legislativo')]
def em_tramitacao():
return [('', 'Tanto Faz'),
(True, 'Sim'),
(False, 'Não')]
def ordenacao_materias():
return [(1, 'Crescente'),
(2, 'Decrescente')]
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in self]))
class ProposicaoForm(ModelForm):
descricao = forms.CharField(
label='Descrição', required=True,
widget=forms.Textarea())
tipo_materia = forms.ModelChoiceField(
label='Matéria Vinculada',
required=False,
queryset=TipoMateriaLegislativa.objects.all(),
empty_label='Selecione',
)
numero_materia = forms.CharField(
label='Número', required=False)
ano_materia = forms.CharField(
label='Ano', required=False)
class Meta:
model = Proposicao
fields = ['tipo',
'descricao',
'texto_original']
exclude = ['autor',
'data_envio',
'data_recebimento',
'data_devolucao',
'justificativa_devolucao',
'numero_proposicao',
'status',
'materia',
'documento']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo', 12)])
row2 = sapl.layout.to_row(
[('descricao', 12)])
row3 = sapl.layout.to_row(
[('tipo_materia', 4),
('numero_materia', 4),
('ano_materia', 4)])
row4 = sapl.layout.to_row(
[('texto_original', 10)])
row4.append(
Column(form_actions(), css_class='col-md-2'))
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Incluir Proposição',
row1, row2, row3, row4)
)
super(ProposicaoForm, self).__init__(
*args, **kwargs)
class DocumentoAcessorioForm(ModelForm):
tipo = forms.ModelChoiceField(
label='Tipo',
required=True,
queryset=TipoDocumento.objects.all(),
empty_label='Selecione',
)
data = forms.DateField(label='Data',
required=False,
input_formats=['%d/%m/%Y'],
widget=forms.TextInput(
attrs={'class': 'dateinput'}))
nome = forms.CharField(
label='Nome', required=True)
autor = forms.CharField(
label='Autor', required=True)
ementa = forms.CharField(
label='Ementa', required=True)
class Meta:
model = DocumentoAcessorio
fields = ['tipo',
'nome',
'data',
'autor',
'ementa']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo', 4),
('nome', 4),
('data', 4)])
row2 = sapl.layout.to_row(
[('autor', 12)])
row3 = sapl.layout.to_row(
[('ementa', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Incluir Documento Acessório',
row1, row2, row3,
form_actions()
)
)
super(DocumentoAcessorioForm, self).__init__(*args, **kwargs)
class RelatoriaForm(ModelForm):
data_designacao_relator = forms.DateField(
label=u'Data Designação',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_destituicao_relator = forms.DateField(
label=u'Data Destituição',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
class Meta:
model = Relatoria
fields = ['data_designacao_relator',
'comissao',
'parlamentar',
'data_destituicao_relator',
'tipo_fim_relatoria'
]
class TramitacaoForm(ModelForm):
data_tramitacao = forms.DateField(label=u'Data Tramitação',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_encaminhamento = forms.DateField(label=u'Data Encaminhamento',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_fim_prazo = forms.DateField(label=u'Data Fim Prazo',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
class Meta:
model = Tramitacao
fields = ['data_tramitacao',
'unidade_tramitacao_local',
'status',
'turno',
'urgente',
'unidade_tramitacao_destino',
'data_encaminhamento',
'data_fim_prazo',
'texto']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('data_tramitacao', 6),
('unidade_tramitacao_local', 6)])
row2 = sapl.layout.to_row(
[('status', 5),
('turno', 5),
('urgente', 2)])
row3 = sapl.layout.to_row(
[('unidade_tramitacao_destino', 12)])
row4 = sapl.layout.to_row(
[('data_encaminhamento', 6),
('data_fim_prazo', 6)])
row5 = sapl.layout.to_row(
[('texto', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Incluir Tramitação',
row1, row2, row3, row4, row5,
),
form_actions()
)
super(TramitacaoForm, self).__init__(
*args, **kwargs)
class LegislacaoCitadaForm(ModelForm):
tipo = forms.ModelChoiceField(
label='Tipo Norma',
required=True,
queryset=TipoNormaJuridica.objects.all(),
empty_label='Selecione',
)
numero = forms.CharField(label='Número', required=True)
ano = forms.CharField(label='Ano', required=True)
disposicao = forms.CharField(label='Disposição', required=False)
parte = forms.CharField(label='Parte', required=False)
livro = forms.CharField(label='Livro', required=False)
titulo = forms.CharField(label='Título', required=False)
capitulo = forms.CharField(label='Capítulo', required=False)
secao = forms.CharField(label='Seção', required=False)
subsecao = forms.CharField(label='Subseção', required=False)
artigo = forms.CharField(label='Artigo', required=False)
paragrafo = forms.CharField(label='Parágrafo', required=False)
inciso = forms.CharField(label='Inciso', required=False)
alinea = forms.CharField(label='Alínea', required=False)
item = forms.CharField(label='Item', required=False)
class Meta:
model = LegislacaoCitada
fields = ['tipo',
'numero',
'ano',
'disposicao',
'parte',
'livro',
'titulo',
'capitulo',
'secao',
'subsecao',
'artigo',
'paragrafo',
'inciso',
'alinea',
'item']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo', 4),
('numero', 4),
('ano', 4)])
row2 = sapl.layout.to_row(
[('disposicao', 3),
('parte', 3),
('livro', 3),
('titulo', 3)])
row3 = sapl.layout.to_row(
[('capitulo', 3),
('secao', 3),
('subsecao', 3),
('artigo', 3)])
row4 = sapl.layout.to_row(
[('paragrafo', 3),
('inciso', 3),
('alinea', 3),
('item', 3)])
self.helper = FormHelper()
self.helper.form_class = 'form-horizontal'
self.helper.layout = Layout(
Fieldset(
'Incluir Legislação Citada',
row1, row2, row3, row4,
form_actions()
)
)
super(LegislacaoCitadaForm, self).__init__(*args, **kwargs)
class NumeracaoForm(ModelForm):
tipo_materia = forms.ModelChoiceField(
label='Tipo de Matéria',
required=True,
queryset=TipoMateriaLegislativa.objects.all(),
empty_label='Selecione',
)
data_materia = forms.DateField(label='Data',
required=False,
input_formats=['%d/%m/%Y'],
widget=forms.TextInput(
attrs={'class': 'dateinput'}))
ano_materia = forms.ChoiceField(required=True,
label='Ano',
choices=get_range_anos(),
widget=forms.Select(
attrs={'class': 'selector'}))
numero_materia = forms.CharField(
label='Número', required=True)
class Meta:
model = Numeracao
fields = ['tipo_materia',
'numero_materia',
'ano_materia',
'data_materia']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo_materia', 12)])
row2 = sapl.layout.to_row(
[('numero_materia', 4),
('ano_materia', 4),
('data_materia', 4)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Incluir Numeração',
row1, row2,
form_actions()
)
)
super(NumeracaoForm, self).__init__(*args, **kwargs)
class DespachoInicialForm(ModelForm):
class Meta:
model = DespachoInicial
fields = ['comissao']
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Adicionar Despacho Inicial',
'comissao',
form_actions()
)
)
super(DespachoInicialForm, self).__init__(*args, **kwargs)
class MateriaAnexadaForm(ModelForm):
tipo = forms.ModelChoiceField(
label='Tipo',
required=True,
queryset=TipoMateriaLegislativa.objects.all(),
empty_label='Selecione',
)
numero = forms.CharField(label='Número', required=True)
ano = forms.CharField(label='Ano', required=True)
data_anexacao = forms.DateField(label='Data Anexação',
required=True,
input_formats=['%d/%m/%Y'],
widget=forms.TextInput(
attrs={'class': 'dateinput'}))
data_desanexacao = forms.DateField(label='Data Desanexação',
required=False,
input_formats=['%d/%m/%Y'],
widget=forms.TextInput(
attrs={'class': 'dateinput'}))
class Meta:
model = Anexada
fields = ['tipo', 'data_anexacao', 'data_desanexacao']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo', 4),
('numero', 4),
('ano', 4)])
row2 = sapl.layout.to_row(
[('data_anexacao', 6),
('data_desanexacao', 6)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Anexar Matéria',
row1, row2,
form_actions()
)
)
super(MateriaAnexadaForm, self).__init__(
*args, **kwargs)
class FormularioSimplificadoForm(ModelForm):
data_apresentacao = forms.DateField(label=u'Data Apresentação',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y'))
class Meta:
model = MateriaLegislativa
fields = ['tipo',
'numero',
'ano',
'data_apresentacao',
'numero_protocolo',
'regime_tramitacao',
'em_tramitacao',
'ementa',
'texto_original']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo', 4),
('numero', 4),
('ano', 4)])
row2 = sapl.layout.to_row(
[('data_apresentacao', 4),
('numero_protocolo', 4),
('regime_tramitacao', 4)])
row3 = sapl.layout.to_row(
[('texto_original', 9),
('em_tramitacao', 3)])
row4 = sapl.layout.to_row(
[('ementa', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Formulário Simplificado',
Fieldset(
'Identificação Básica',
row1, row2, row3, row4
),
form_actions()
)
)
super(FormularioSimplificadoForm, self).__init__(*args, **kwargs)
class FormularioCadastroForm(ModelForm):
class Meta:
model = MateriaLegislativa
fields = ['tipo',
'numero',
'ano',
'data_apresentacao',
'numero_protocolo',
'tipo_apresentacao',
'texto_original',
'apelido',
'dias_prazo',
'polemica',
'objeto',
'regime_tramitacao',
'em_tramitacao',
'data_fim_prazo',
'data_publicacao',
'complementar',
'tipo_origem_externa',
'numero_origem_externa',
'ano_origem_externa',
'local_origem_externa',
'data_origem_externa',
'ementa',
'indexacao',
'observacao']
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Formulário de Cadastro',
Fieldset(
'Identificação Básica',
'tipo',
'numero',
'ano',
'data_apresentacao',
'numero_protocolo',
'tipo_apresentacao',
'texto_original'
),
Fieldset(
'Outras Informações',
'apelido',
'dias_prazo',
'polemica',
'objeto',
'regime_tramitacao',
'em_tramitacao',
'data_fim_prazo',
'data_publicacao',
'complementar'
),
Fieldset(
'Origem Externa',
'tipo_origem_externa',
'numero_origem_externa',
'ano_origem_externa',
'local_origem_externa',
'data_origem_externa'
),
Fieldset(
'Dados Textuais',
'ementa',
'indexacao',
'observacao'
),
form_actions()
)
)
super(FormularioCadastroForm, self).__init__(*args, **kwargs)
class AutoriaForm(forms.Form):
tipo_autor = forms.CharField()
nome_autor = forms.CharField()
primeiro_autor = forms.CharField()
partido_autor = forms.ModelChoiceField(
label='Partido (Autor)',
required=False,
queryset=Partido.objects.all(),
empty_label='Selecione')
class MateriaLegislativaPesquisaForm(forms.Form):
autor = forms.ModelChoiceField(
label='Autor',
required=False,
queryset=Autor.objects.all().order_by('tipo'),
empty_label='Selecione',
)
# relatores são os parlamentares ativos?
relator = forms.ModelChoiceField(
label='Relator',
required=False,
queryset=Parlamentar.objects.all().order_by('nome_parlamentar'),
empty_label='Selecione',
)
tipo = forms.ModelChoiceField(
label='Tipo de Matéria',
required=False,
queryset=TipoMateriaLegislativa.objects.all(),
empty_label='Selecione',
)
data_apresentacao = forms.DateField(label=u'Data de Apresentação',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_publicacao = forms.DateField(label=u'Data da Publicação',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
numero = forms.CharField(required=False, label=u'Número da Matéria')
numero_protocolo = forms.CharField(required=False, label=u'Núm. Protocolo')
ano = forms.CharField(required=False, label=u'Ano da Matéria')
assunto = forms.CharField(required=False, label=u'Assunto')
ordem = forms.ChoiceField(required=False,
label='Ordenação',
choices=ordenacao_materias(),
widget=forms.Select(
attrs={'class': 'selector'}))
localizacao = forms.ModelChoiceField(
label='Localização Atual',
required=False,
queryset=UnidadeTramitacao.objects.all(),
empty_label='Selecione',
)
situacao = forms.ModelChoiceField(
label='Situação',
required=False,
queryset=StatusTramitacao.objects.all(),
empty_label='Selecione',
)
tramitacao = forms.ChoiceField(required=False,
label='Tramitando',
choices=em_tramitacao(),
widget=forms.Select(
attrs={'class': 'selector'}))
tipo_autor = forms.ModelChoiceField(
label='Tipo Autor',
required=False,
queryset=TipoAutor.objects.all(),
empty_label='Selecione',
)
partido_autor = forms.ModelChoiceField(
label='Partido (Autor)',
required=False,
queryset=Partido.objects.all(),
empty_label='Selecione')
local_origem_externa = forms.ModelChoiceField(
label='Localização de Origem',
required=False,
queryset=Origem.objects.all(),
empty_label='Selecione')
# TODO: Verificar se esses campos estão corretos
# assunto? # -> usado 'ementa' em 'assunto'
# localizacao atual? #
# situacao? #
# tramitando? #
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo', 12)])
row2 = sapl.layout.to_row(
[('numero', 4),
('ano', 4),
('numero_protocolo', 4)])
row3 = sapl.layout.to_row(
[('data_apresentacao', 6),
('data_publicacao', 6)])
row4 = sapl.layout.to_row(
[('autor', 6),
('partido_autor', 6)])
row5 = sapl.layout.to_row(
[('tipo_autor', 6),
('relator', 6)])
row6 = sapl.layout.to_row(
[('local_origem_externa', 6),
('localizacao', 6)])
row7 = sapl.layout.to_row(
[('tramitacao', 4),
('situacao', 4),
('ordem', 4)])
row8 = sapl.layout.to_row(
[('assunto', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Pesquisa Básica',
row1, row2, row3, row4, row5, row6, row7, row8),
form_actions(save_label='Pesquisar')
)
super(MateriaLegislativaPesquisaForm, self).__init__(
*args, **kwargs)

837
materia/views.py

@ -1,17 +1,12 @@
from datetime import date, datetime from datetime import datetime
from re import sub from re import sub
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Column, Fieldset, Layout
from django import forms
from django.contrib import messages from django.contrib import messages
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.core.mail import send_mail from django.core.mail import send_mail
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.forms import ModelForm
from django.shortcuts import redirect from django.shortcuts import redirect
from django.utils.html import strip_tags from django.utils.html import strip_tags
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import ListView from django.views.generic import ListView
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
@ -21,11 +16,15 @@ import sapl
from comissoes.models import Comissao, Composicao from comissoes.models import Comissao, Composicao
from compilacao.views import IntegracaoTaView from compilacao.views import IntegracaoTaView
from norma.models import LegislacaoCitada, NormaJuridica, TipoNormaJuridica from norma.models import LegislacaoCitada, NormaJuridica, TipoNormaJuridica
from parlamentares.models import Parlamentar, Partido from parlamentares.models import Partido
from sapl.crud import build_crud from sapl.crud import build_crud
from sapl.layout import form_actions
from sessao.models import AcompanharMateria from sessao.models import AcompanharMateria
from .forms import (AutoriaForm, DespachoInicialForm, DocumentoAcessorioForm,
FormularioCadastroForm, FormularioSimplificadoForm,
LegislacaoCitadaForm, MateriaAnexadaForm,
MateriaLegislativaPesquisaForm, NumeracaoForm,
ProposicaoForm, RelatoriaForm, TramitacaoForm)
from .models import (Anexada, Autor, Autoria, DespachoInicial, from .models import (Anexada, Autor, Autoria, DespachoInicial,
DocumentoAcessorio, MateriaLegislativa, Numeracao, Orgao, DocumentoAcessorio, MateriaLegislativa, Numeracao, Orgao,
Origem, Proposicao, RegimeTramitacao, Relatoria, Origem, Proposicao, RegimeTramitacao, Relatoria,
@ -228,157 +227,6 @@ tramitacao_crud = build_crud(
]) ])
def get_range_anos():
return [('', 'Selecione')] \
+ [(year, year) for year in range(date.today().year, 1960, -1)]
def get_regimes_tramitacao():
return [('1', 'Normal'),
('3', 'Urgência'),
('4', 'Urgência Especial')]
def get_local_origem():
return [('E', 'Poder Executivo'),
('L', 'Poder Legislativo')]
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in self]))
class FormularioSimplificadoForm(ModelForm):
data_apresentacao = forms.DateField(label=u'Data Apresentação',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y'))
class Meta:
model = MateriaLegislativa
fields = ['tipo',
'numero',
'ano',
'data_apresentacao',
'numero_protocolo',
'regime_tramitacao',
'em_tramitacao',
'ementa',
'texto_original']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo', 4),
('numero', 4),
('ano', 4)])
row2 = sapl.layout.to_row(
[('data_apresentacao', 4),
('numero_protocolo', 4),
('regime_tramitacao', 4)])
row3 = sapl.layout.to_row(
[('texto_original', 9),
('em_tramitacao', 3)])
row4 = sapl.layout.to_row(
[('ementa', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Formulário Simplificado',
Fieldset(
'Identificação Básica',
row1, row2, row3, row4
),
form_actions()
)
)
super(FormularioSimplificadoForm, self).__init__(*args, **kwargs)
class FormularioCadastroForm(ModelForm):
class Meta:
model = MateriaLegislativa
fields = ['tipo',
'numero',
'ano',
'data_apresentacao',
'numero_protocolo',
'tipo_apresentacao',
'texto_original',
'apelido',
'dias_prazo',
'polemica',
'objeto',
'regime_tramitacao',
'em_tramitacao',
'data_fim_prazo',
'data_publicacao',
'complementar',
'tipo_origem_externa',
'numero_origem_externa',
'ano_origem_externa',
'local_origem_externa',
'data_origem_externa',
'ementa',
'indexacao',
'observacao']
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Formulário de Cadastro',
Fieldset(
'Identificação Básica',
'tipo',
'numero',
'ano',
'data_apresentacao',
'numero_protocolo',
'tipo_apresentacao',
'texto_original'
),
Fieldset(
'Outras Informações',
'apelido',
'dias_prazo',
'polemica',
'objeto',
'regime_tramitacao',
'em_tramitacao',
'data_fim_prazo',
'data_publicacao',
'complementar'
),
Fieldset(
'Origem Externa',
'tipo_origem_externa',
'numero_origem_externa',
'ano_origem_externa',
'local_origem_externa',
'data_origem_externa'
),
Fieldset(
'Dados Textuais',
'ementa',
'indexacao',
'observacao'
),
form_actions()
)
)
super(FormularioCadastroForm, self).__init__(*args, **kwargs)
class FormularioSimplificadoView(FormMixin, GenericView): class FormularioSimplificadoView(FormMixin, GenericView):
template_name = "materia/formulario_simplificado.html" template_name = "materia/formulario_simplificado.html"
@ -423,57 +271,6 @@ class FormularioCadastroView(FormMixin, GenericView):
return reverse('formulario_cadastro') return reverse('formulario_cadastro')
class MateriaAnexadaForm(ModelForm):
tipo = forms.ModelChoiceField(
label='Tipo',
required=True,
queryset=TipoMateriaLegislativa.objects.all(),
empty_label='Selecione',
)
numero = forms.CharField(label='Número', required=True)
ano = forms.CharField(label='Ano', required=True)
data_anexacao = forms.DateField(label='Data Anexação',
required=True,
input_formats=['%d/%m/%Y'],
widget=forms.TextInput(
attrs={'class': 'dateinput'}))
data_desanexacao = forms.DateField(label='Data Desanexação',
required=False,
input_formats=['%d/%m/%Y'],
widget=forms.TextInput(
attrs={'class': 'dateinput'}))
class Meta:
model = Anexada
fields = ['tipo', 'data_anexacao', 'data_desanexacao']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo', 4),
('numero', 4),
('ano', 4)])
row2 = sapl.layout.to_row(
[('data_anexacao', 6),
('data_desanexacao', 6)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Anexar Matéria',
row1, row2,
form_actions()
)
)
super(MateriaAnexadaForm, self).__init__(
*args, **kwargs)
class MateriaAnexadaView(FormMixin, GenericView): class MateriaAnexadaView(FormMixin, GenericView):
template_name = "materia/materia_anexada.html" template_name = "materia/materia_anexada.html"
@ -634,31 +431,13 @@ class MateriaAnexadaEditView(FormMixin, GenericView):
return reverse('materia_anexada', kwargs={'pk': pk}) return reverse('materia_anexada', kwargs={'pk': pk})
class DespachoInicialFom(ModelForm):
class Meta:
model = DespachoInicial
fields = ['comissao']
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Adicionar Despacho Inicial',
'comissao',
form_actions()
)
)
super(DespachoInicialFom, self).__init__(*args, **kwargs)
class DespachoInicialView(FormMixin, GenericView): class DespachoInicialView(FormMixin, GenericView):
template_name = "materia/despacho_inicial.html" template_name = "materia/despacho_inicial.html"
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
materia = MateriaLegislativa.objects.get(id=kwargs['pk']) materia = MateriaLegislativa.objects.get(id=kwargs['pk'])
despacho = DespachoInicial.objects.filter(materia_id=materia.id) despacho = DespachoInicial.objects.filter(materia_id=materia.id)
form = DespachoInicialFom() form = DespachoInicialForm()
return self.render_to_response( return self.render_to_response(
{'object': materia, {'object': materia,
@ -666,7 +445,7 @@ class DespachoInicialView(FormMixin, GenericView):
'despachos': despacho}) 'despachos': despacho})
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = DespachoInicialFom(request.POST) form = DespachoInicialForm(request.POST)
materia = MateriaLegislativa.objects.get(id=kwargs['pk']) materia = MateriaLegislativa.objects.get(id=kwargs['pk'])
despacho = DespachoInicial.objects.filter(materia_id=materia.id) despacho = DespachoInicial.objects.filter(materia_id=materia.id)
@ -692,7 +471,7 @@ class DespachoInicialEditView(FormMixin, GenericView):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
materia = MateriaLegislativa.objects.get(id=kwargs['pk']) materia = MateriaLegislativa.objects.get(id=kwargs['pk'])
despacho = DespachoInicial.objects.get(id=kwargs['id']) despacho = DespachoInicial.objects.get(id=kwargs['id'])
form = DespachoInicialFom() form = DespachoInicialForm()
return self.render_to_response( return self.render_to_response(
{'object': materia, {'object': materia,
@ -701,7 +480,7 @@ class DespachoInicialEditView(FormMixin, GenericView):
'comissoes': Comissao.objects.all()}) 'comissoes': Comissao.objects.all()})
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = DespachoInicialFom(request.POST) form = DespachoInicialForm(request.POST)
materia = MateriaLegislativa.objects.get(id=kwargs['pk']) materia = MateriaLegislativa.objects.get(id=kwargs['pk'])
despacho = DespachoInicial.objects.get(id=kwargs['id']) despacho = DespachoInicial.objects.get(id=kwargs['id'])
@ -726,98 +505,6 @@ class DespachoInicialEditView(FormMixin, GenericView):
return reverse('despacho_inicial', kwargs={'pk': pk}) return reverse('despacho_inicial', kwargs={'pk': pk})
class LegislacaoCitadaForm(ModelForm):
tipo = forms.ModelChoiceField(
label='Tipo Norma',
required=True,
queryset=TipoNormaJuridica.objects.all(),
empty_label='Selecione',
)
numero = forms.CharField(label='Número', required=True)
ano = forms.CharField(label='Ano', required=True)
disposicao = forms.CharField(label='Disposição', required=False)
parte = forms.CharField(label='Parte', required=False)
livro = forms.CharField(label='Livro', required=False)
titulo = forms.CharField(label='Título', required=False)
capitulo = forms.CharField(label='Capítulo', required=False)
secao = forms.CharField(label='Seção', required=False)
subsecao = forms.CharField(label='Subseção', required=False)
artigo = forms.CharField(label='Artigo', required=False)
paragrafo = forms.CharField(label='Parágrafo', required=False)
inciso = forms.CharField(label='Inciso', required=False)
alinea = forms.CharField(label='Alínea', required=False)
item = forms.CharField(label='Item', required=False)
class Meta:
model = LegislacaoCitada
fields = ['tipo',
'numero',
'ano',
'disposicao',
'parte',
'livro',
'titulo',
'capitulo',
'secao',
'subsecao',
'artigo',
'paragrafo',
'inciso',
'alinea',
'item']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo', 4),
('numero', 4),
('ano', 4)])
row2 = sapl.layout.to_row(
[('disposicao', 3),
('parte', 3),
('livro', 3),
('titulo', 3)])
row3 = sapl.layout.to_row(
[('capitulo', 3),
('secao', 3),
('subsecao', 3),
('artigo', 3)])
row4 = sapl.layout.to_row(
[('paragrafo', 3),
('inciso', 3),
('alinea', 3),
('item', 3)])
self.helper = FormHelper()
self.helper.form_class = 'form-horizontal'
self.helper.layout = Layout(
Fieldset(
'Incluir Legislação Citada',
row1, row2, row3, row4,
form_actions()
)
)
super(LegislacaoCitadaForm, self).__init__(*args, **kwargs)
class LegislacaoCitadaView(FormMixin, GenericView): class LegislacaoCitadaView(FormMixin, GenericView):
template_name = "materia/legislacao_citada.html" template_name = "materia/legislacao_citada.html"
@ -942,57 +629,6 @@ class LegislacaoCitadaEditView(FormMixin, GenericView):
'object': materia}) 'object': materia})
class NumeracaoForm(ModelForm):
tipo_materia = forms.ModelChoiceField(
label='Tipo de Matéria',
required=True,
queryset=TipoMateriaLegislativa.objects.all(),
empty_label='Selecione',
)
data_materia = forms.DateField(label='Data',
required=False,
input_formats=['%d/%m/%Y'],
widget=forms.TextInput(
attrs={'class': 'dateinput'}))
ano_materia = forms.ChoiceField(required=True,
label='Ano',
choices=get_range_anos(),
widget=forms.Select(
attrs={'class': 'selector'}))
numero_materia = forms.CharField(
label='Número', required=True)
class Meta:
model = Numeracao
fields = ['tipo_materia',
'numero_materia',
'ano_materia',
'data_materia']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo_materia', 12)])
row2 = sapl.layout.to_row(
[('numero_materia', 4),
('ano_materia', 4),
('data_materia', 4)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Incluir Numeração',
row1, row2,
form_actions()
)
)
super(NumeracaoForm, self).__init__(*args, **kwargs)
class NumeracaoView(FormMixin, GenericView): class NumeracaoView(FormMixin, GenericView):
template_name = "materia/numeracao.html" template_name = "materia/numeracao.html"
@ -1079,62 +715,6 @@ class NumeracaoEditView(FormMixin, GenericView):
return reverse('numeracao', kwargs={'pk': pk}) return reverse('numeracao', kwargs={'pk': pk})
class DocumentoAcessorioForm(ModelForm):
tipo = forms.ModelChoiceField(
label='Tipo',
required=True,
queryset=TipoDocumento.objects.all(),
empty_label='Selecione',
)
data = forms.DateField(label='Data',
required=False,
input_formats=['%d/%m/%Y'],
widget=forms.TextInput(
attrs={'class': 'dateinput'}))
nome = forms.CharField(
label='Nome', required=True)
autor = forms.CharField(
label='Autor', required=True)
ementa = forms.CharField(
label='Ementa', required=True)
class Meta:
model = DocumentoAcessorio
fields = ['tipo',
'nome',
'data',
'autor',
'ementa']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo', 4),
('nome', 4),
('data', 4)])
row2 = sapl.layout.to_row(
[('autor', 12)])
row3 = sapl.layout.to_row(
[('ementa', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Incluir Documento Acessório',
row1, row2, row3,
form_actions()
)
)
super(DocumentoAcessorioForm, self).__init__(*args, **kwargs)
class DocumentoAcessorioView(FormMixin, GenericView): class DocumentoAcessorioView(FormMixin, GenericView):
template_name = "materia/documento_acessorio.html" template_name = "materia/documento_acessorio.html"
@ -1222,33 +802,6 @@ class DocumentoAcessorioEditView(FormMixin, GenericView):
return reverse('documento_acessorio', kwargs={'pk': pk}) return reverse('documento_acessorio', kwargs={'pk': pk})
class RelatoriaForm(ModelForm):
data_designacao_relator = forms.DateField(
label=u'Data Designação',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_destituicao_relator = forms.DateField(
label=u'Data Destituição',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
class Meta:
model = Relatoria
fields = ['data_designacao_relator',
'comissao',
'parlamentar',
'data_destituicao_relator',
'tipo_fim_relatoria'
]
class RelatoriaEditView(FormMixin, GenericView): class RelatoriaEditView(FormMixin, GenericView):
template_name = "materia/relatoria_edit.html" template_name = "materia/relatoria_edit.html"
@ -1414,72 +967,6 @@ class RelatoriaView(FormMixin, GenericView):
'parlamentares': parlamentares}) 'parlamentares': parlamentares})
class TramitacaoForm(ModelForm):
data_tramitacao = forms.DateField(label=u'Data Tramitação',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_encaminhamento = forms.DateField(label=u'Data Encaminhamento',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_fim_prazo = forms.DateField(label=u'Data Fim Prazo',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
class Meta:
model = Tramitacao
fields = ['data_tramitacao',
'unidade_tramitacao_local',
'status',
'turno',
'urgente',
'unidade_tramitacao_destino',
'data_encaminhamento',
'data_fim_prazo',
'texto']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('data_tramitacao', 6),
('unidade_tramitacao_local', 6)])
row2 = sapl.layout.to_row(
[('status', 5),
('turno', 5),
('urgente', 2)])
row3 = sapl.layout.to_row(
[('unidade_tramitacao_destino', 12)])
row4 = sapl.layout.to_row(
[('data_encaminhamento', 6),
('data_fim_prazo', 6)])
row5 = sapl.layout.to_row(
[('texto', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Incluir Tramitação',
row1, row2, row3, row4, row5,
),
form_actions()
)
super(TramitacaoForm, self).__init__(
*args, **kwargs)
class TramitacaoView(FormMixin, GenericView): class TramitacaoView(FormMixin, GenericView):
template_name = "materia/tramitacao.html" template_name = "materia/tramitacao.html"
@ -1606,17 +1093,6 @@ class TramitacaoEditView(FormMixin, GenericView):
return reverse('tramitacao_materia', kwargs={'pk': pk}) return reverse('tramitacao_materia', kwargs={'pk': pk})
class AutoriaForm(forms.Form):
tipo_autor = forms.CharField()
nome_autor = forms.CharField()
primeiro_autor = forms.CharField()
partido_autor = forms.ModelChoiceField(
label='Partido (Autor)',
required=False,
queryset=Partido.objects.all(),
empty_label='Selecione')
class AutoriaView(GenericView): class AutoriaView(GenericView):
template_name = "materia/autoria.html" template_name = "materia/autoria.html"
@ -1761,110 +1237,6 @@ class AutoriaEditView(GenericView, FormMixin):
return reverse('autoria', kwargs={'pk': pk}) return reverse('autoria', kwargs={'pk': pk})
class ProposicaoForm(ModelForm):
descricao = forms.CharField(
label='Descrição', required=True,
widget=forms.Textarea())
tipo_materia = forms.ModelChoiceField(
label='Matéria Vinculada',
required=False,
queryset=TipoMateriaLegislativa.objects.all(),
empty_label='Selecione',
)
numero_materia = forms.CharField(
label='Número', required=False)
ano_materia = forms.CharField(
label='Ano', required=False)
class Meta:
model = Proposicao
fields = ['tipo',
'descricao',
'texto_original']
exclude = ['autor',
'data_envio',
'data_recebimento',
'data_devolucao',
'justificativa_devolucao',
'numero_proposicao',
'status',
'materia',
'documento']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo', 12)])
row2 = sapl.layout.to_row(
[('descricao', 12)])
row3 = sapl.layout.to_row(
[('tipo_materia', 4),
('numero_materia', 4),
('ano_materia', 4)])
row4 = sapl.layout.to_row(
[('texto_original', 10)])
row4.append(
Column(form_actions(), css_class='col-md-2'))
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Incluir Proposição',
row1, row2, row3, row4)
)
super(ProposicaoForm, self).__init__(
*args, **kwargs)
class ProposicaoView(FormMixin, GenericView):
template_name = "materia/proposicao.html"
def get_success_url(self):
return reverse('list_proposicao')
def get(self, request, *args, **kwargs):
form = ProposicaoForm()
return self.render_to_response({'form': form})
def post(self, request, *args, **kwargs):
form = ProposicaoForm(request.POST)
if form.is_valid():
proposicao = form.save(commit=False)
if 'texto_original' in request.FILES:
proposicao.texto_original = request.FILES['texto_original']
tipo = TipoProposicao.objects.get(
id=int(request.POST['tipo']))
if tipo.descricao == 'Parecer':
try:
materia = MateriaLegislativa.objects.get(
tipo_id=int(form.data['tipo_materia']),
ano=int(form.data['ano_materia']),
numero=int(form.data['numero_materia']))
except ObjectDoesNotExist:
msg = 'Matéria adicionada não existe!'
messages.add_message(request, messages.INFO, msg)
return self.render_to_response({'form': form})
else:
proposicao.autor = materia.autoria_set.first().autor
proposicao.materia = materia
proposicao.descricao = sub('&nbsp;',
' ',
strip_tags(form.data['descricao']))
# proposicao.data_envio = datetime.now()
proposicao.save()
return self.form_valid(form)
else:
return self.render_to_response({'form': form})
class ProposicaoListView(ListView): class ProposicaoListView(ListView):
template_name = "materia/proposicao_list.html" template_name = "materia/proposicao_list.html"
paginate_by = 10 paginate_by = 10
@ -1884,148 +1256,6 @@ class ProposicaoListView(ListView):
return context return context
def em_tramitacao():
return [('', 'Tanto Faz'),
(True, 'Sim'),
(False, 'Não')]
def ordenacao_materias():
return [(1, 'Crescente'),
(2, 'Decrescente')]
class MateriaLegislativaPesquisaForm(forms.Form):
autor = forms.ModelChoiceField(
label='Autor',
required=False,
queryset=Autor.objects.all().order_by('tipo'),
empty_label='Selecione',
)
# relatores são os parlamentares ativos?
relator = forms.ModelChoiceField(
label='Relator',
required=False,
queryset=Parlamentar.objects.all().order_by('nome_parlamentar'),
empty_label='Selecione',
)
tipo = forms.ModelChoiceField(
label='Tipo de Matéria',
required=False,
queryset=TipoMateriaLegislativa.objects.all(),
empty_label='Selecione',
)
data_apresentacao = forms.DateField(label=u'Data de Apresentação',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_publicacao = forms.DateField(label=u'Data da Publicação',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
numero = forms.CharField(required=False, label=u'Número da Matéria')
numero_protocolo = forms.CharField(required=False, label=u'Núm. Protocolo')
ano = forms.CharField(required=False, label=u'Ano da Matéria')
assunto = forms.CharField(required=False, label=u'Assunto')
ordem = forms.ChoiceField(required=False,
label='Ordenação',
choices=ordenacao_materias(),
widget=forms.Select(
attrs={'class': 'selector'}))
localizacao = forms.ModelChoiceField(
label='Localização Atual',
required=False,
queryset=UnidadeTramitacao.objects.all(),
empty_label='Selecione',
)
situacao = forms.ModelChoiceField(
label='Situação',
required=False,
queryset=StatusTramitacao.objects.all(),
empty_label='Selecione',
)
tramitacao = forms.ChoiceField(required=False,
label='Tramitando',
choices=em_tramitacao(),
widget=forms.Select(
attrs={'class': 'selector'}))
tipo_autor = forms.ModelChoiceField(
label='Tipo Autor',
required=False,
queryset=TipoAutor.objects.all(),
empty_label='Selecione',
)
partido_autor = forms.ModelChoiceField(
label='Partido (Autor)',
required=False,
queryset=Partido.objects.all(),
empty_label='Selecione')
local_origem_externa = forms.ModelChoiceField(
label='Localização de Origem',
required=False,
queryset=Origem.objects.all(),
empty_label='Selecione')
# TODO: Verificar se esses campos estão corretos
# assunto? # -> usado 'ementa' em 'assunto'
# localizacao atual? #
# situacao? #
# tramitando? #
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo', 12)])
row2 = sapl.layout.to_row(
[('numero', 4),
('ano', 4),
('numero_protocolo', 4)])
row3 = sapl.layout.to_row(
[('data_apresentacao', 6),
('data_publicacao', 6)])
row4 = sapl.layout.to_row(
[('autor', 6),
('partido_autor', 6)])
row5 = sapl.layout.to_row(
[('tipo_autor', 6),
('relator', 6)])
row6 = sapl.layout.to_row(
[('local_origem_externa', 6),
('localizacao', 6)])
row7 = sapl.layout.to_row(
[('tramitacao', 4),
('situacao', 4),
('ordem', 4)])
row8 = sapl.layout.to_row(
[('assunto', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Pesquisa Básica',
row1, row2, row3, row4, row5, row6, row7, row8),
form_actions(save_label='Pesquisar')
)
super(MateriaLegislativaPesquisaForm, self).__init__(
*args, **kwargs)
class MateriaLegislativaPesquisaView(FormMixin, GenericView): class MateriaLegislativaPesquisaView(FormMixin, GenericView):
template_name = 'materia/pesquisa_materia.html' template_name = 'materia/pesquisa_materia.html'
@ -2209,6 +1439,51 @@ class PesquisaMateriaListView(FormMixin, ListView):
return context return context
class ProposicaoView(FormMixin, GenericView):
template_name = "materia/proposicao.html"
def get_success_url(self):
return reverse('list_proposicao')
def get(self, request, *args, **kwargs):
form = ProposicaoForm()
return self.render_to_response({'form': form})
def post(self, request, *args, **kwargs):
form = ProposicaoForm(request.POST)
if form.is_valid():
proposicao = form.save(commit=False)
if 'texto_original' in request.FILES:
proposicao.texto_original = request.FILES['texto_original']
tipo = TipoProposicao.objects.get(
id=int(request.POST['tipo']))
if tipo.descricao == 'Parecer':
try:
materia = MateriaLegislativa.objects.get(
tipo_id=int(form.data['tipo_materia']),
ano=int(form.data['ano_materia']),
numero=int(form.data['numero_materia']))
except ObjectDoesNotExist:
msg = 'Matéria adicionada não existe!'
messages.add_message(request, messages.INFO, msg)
return self.render_to_response({'form': form})
else:
proposicao.autor = materia.autoria_set.first().autor
proposicao.materia = materia
proposicao.descricao = sub('&nbsp;',
' ',
strip_tags(form.data['descricao']))
# proposicao.data_envio = datetime.now()
proposicao.save()
return self.form_valid(form)
else:
return self.render_to_response({'form': form})
class MateriaTaView(IntegracaoTaView): class MateriaTaView(IntegracaoTaView):
model = MateriaLegislativa model = MateriaLegislativa

102
norma/forms.py

@ -0,0 +1,102 @@
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Fieldset, Layout
from django import forms
from django.forms import ModelForm
from django.utils.safestring import mark_safe
import sapl
from materia.models import TipoMateriaLegislativa
from sapl.layout import form_actions
from .models import NormaJuridica
def get_esferas():
return [('E', 'Estadual'),
('F', 'Federal'),
('M', 'Municipal')]
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in self]))
class NormaJuridicaForm(ModelForm):
tipo_materia = forms.ModelChoiceField(
label='Matéria Legislativa',
required=False,
queryset=TipoMateriaLegislativa.objects.all(),
empty_label='Selecione'
)
numero_materia = forms.CharField(label='Número', required=False)
ano_materia = forms.CharField(label='Ano', required=False)
class Meta:
model = NormaJuridica
fields = ['tipo',
'numero',
'ano',
'data',
'esfera_federacao',
'complemento',
'tipo_materia',
'numero_materia',
'ano_materia',
'data_publicacao',
'veiculo_publicacao',
'pagina_inicio_publicacao',
'pagina_fim_publicacao',
'ementa',
'indexacao',
'observacao',
'texto_integral']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo', 4),
('numero', 4),
('ano', 4)])
row2 = sapl.layout.to_row(
[('data', 4),
('esfera_federacao', 4),
('complemento', 4)])
row3 = sapl.layout.to_row(
[('tipo_materia', 4),
('numero_materia', 4),
('ano_materia', 4)])
row4 = sapl.layout.to_row(
[('data_publicacao', 3),
('veiculo_publicacao', 3),
('pagina_inicio_publicacao', 3),
('pagina_fim_publicacao', 3)])
row5 = sapl.layout.to_row(
[('texto_integral', 12)])
row6 = sapl.layout.to_row(
[('ementa', 12)])
row7 = sapl.layout.to_row(
[('indexacao', 12)])
row8 = sapl.layout.to_row(
[('observacao', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Cadastro de Norma Jurídica',
Fieldset('Identificação Básica',
row1, row2, row3, row4, row5, row6, row7, row8),
form_actions()
)
)
super(NormaJuridicaForm, self).__init__(*args, **kwargs)

99
norma/views.py

@ -1,23 +1,17 @@
from datetime import datetime from datetime import datetime
from re import sub from re import sub
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Fieldset, Layout
from django import forms
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.forms import ModelForm
from django.utils.html import strip_tags from django.utils.html import strip_tags
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from vanilla.views import GenericView from vanilla.views import GenericView
import sapl
from compilacao.views import IntegracaoTaView from compilacao.views import IntegracaoTaView
from materia.models import MateriaLegislativa, TipoMateriaLegislativa from materia.models import MateriaLegislativa, TipoMateriaLegislativa
from sapl.crud import build_crud from sapl.crud import build_crud
from sapl.layout import form_actions
from .forms import NormaJuridicaForm
from .models import (AssuntoNorma, LegislacaoCitada, NormaJuridica, from .models import (AssuntoNorma, LegislacaoCitada, NormaJuridica,
TipoNormaJuridica) TipoNormaJuridica)
@ -79,97 +73,6 @@ legislacao_citada_crud = build_crud(
]) ])
def get_esferas():
return [('E', 'Estadual'),
('F', 'Federal'),
('M', 'Municipal')]
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in self]))
class NormaJuridicaForm(ModelForm):
tipo_materia = forms.ModelChoiceField(
label='Matéria Legislativa',
required=False,
queryset=TipoMateriaLegislativa.objects.all(),
empty_label='Selecione'
)
numero_materia = forms.CharField(label='Número', required=False)
ano_materia = forms.CharField(label='Ano', required=False)
class Meta:
model = NormaJuridica
fields = ['tipo',
'numero',
'ano',
'data',
'esfera_federacao',
'complemento',
'tipo_materia',
'numero_materia',
'ano_materia',
'data_publicacao',
'veiculo_publicacao',
'pagina_inicio_publicacao',
'pagina_fim_publicacao',
'ementa',
'indexacao',
'observacao',
'texto_integral']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('tipo', 4),
('numero', 4),
('ano', 4)])
row2 = sapl.layout.to_row(
[('data', 4),
('esfera_federacao', 4),
('complemento', 4)])
row3 = sapl.layout.to_row(
[('tipo_materia', 4),
('numero_materia', 4),
('ano_materia', 4)])
row4 = sapl.layout.to_row(
[('data_publicacao', 3),
('veiculo_publicacao', 3),
('pagina_inicio_publicacao', 3),
('pagina_fim_publicacao', 3)])
row5 = sapl.layout.to_row(
[('texto_integral', 12)])
row6 = sapl.layout.to_row(
[('ementa', 12)])
row7 = sapl.layout.to_row(
[('indexacao', 12)])
row8 = sapl.layout.to_row(
[('observacao', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Cadastro de Norma Jurídica',
Fieldset('Identificação Básica',
row1, row2, row3, row4, row5, row6, row7, row8),
form_actions()
)
)
super(NormaJuridicaForm, self).__init__(*args, **kwargs)
class NormaIncluirView(FormMixin, GenericView): class NormaIncluirView(FormMixin, GenericView):
template_name = "norma/normajuridica_incluir.html" template_name = "norma/normajuridica_incluir.html"

324
parlamentares/forms.py

@ -0,0 +1,324 @@
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Fieldset, Layout, Submit
from django import forms
from django.forms import ModelForm
from django.utils.safestring import mark_safe
import sapl
from sapl.layout import form_actions
from .models import Dependente, Filiacao, Mandato, Parlamentar
class ParlamentaresListForm(forms.Form):
periodo = forms.CharField()
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in self]))
class ParlamentaresForm (ModelForm):
ativo = forms.TypedChoiceField(
coerce=lambda x: x == 'True',
choices=((True, 'Sim'), (False, 'Não')),
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer
)
)
cpf = forms.CharField(label='C.P.F',
required=False,
widget=forms.TextInput(
attrs={'class': 'cpf'}))
rg = forms.CharField(label='R.G.',
required=False,
widget=forms.TextInput(
attrs={'class': 'rg'}))
titulo_eleitor = forms.CharField(label='Título de Eleitor',
required=False,
widget=forms.TextInput(
attrs={'class': 'titulo_eleitor'}))
telefone = forms.CharField(label='Telefone',
required=False,
widget=forms.TextInput(
attrs={'class': 'telefone'}))
fax = forms.CharField(label='Fax',
required=False,
widget=forms.TextInput(
attrs={'class': 'telefone'}))
cep_residencia = forms.CharField(label='CEP',
required=False,
widget=forms.TextInput(
attrs={'class': 'cep'}))
telefone_residencia = forms.CharField(label='Telefone',
required=False,
widget=forms.TextInput(
attrs={'class': 'telefone'}))
fax_residencia = forms.CharField(label='Fax',
required=False,
widget=forms.TextInput(
attrs={'class': 'telefone'}))
fotografia = forms.ImageField(label='Fotografia',
required=False,
widget=forms.FileInput
)
class Meta:
model = Parlamentar
fields = ['nome_parlamentar',
'ativo',
'nome_completo',
'nivel_instrucao',
'sexo',
'cpf',
'rg',
'titulo_eleitor',
'data_nascimento',
'situacao_militar',
'profissao',
'endereco_web',
'email',
'numero_gab_parlamentar',
'telefone',
'fax',
'endereco_residencia',
'cep_residencia',
'municipio_residencia',
'telefone_residencia',
'fax_residencia',
'locais_atuacao',
'fotografia',
'biografia']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('nome_parlamentar', 8), ('ativo', 4)])
row2 = sapl.layout.to_row(
[('nome_completo', 12)])
row3 = sapl.layout.to_row(
[('nivel_instrucao', 4),
('sexo', 4),
('data_nascimento', 4)])
row4 = sapl.layout.to_row(
[('cpf', 4),
('rg', 4),
('titulo_eleitor', 4)])
row5 = sapl.layout.to_row(
[('situacao_militar', 6),
('profissao', 6)])
row6 = sapl.layout.to_row(
[('endereco_web', 12)])
row7 = sapl.layout.to_row(
[('email', 12)])
row8 = sapl.layout.to_row(
[('numero_gab_parlamentar', 4),
('telefone', 4),
('fax', 4)])
row9 = sapl.layout.to_row(
[('endereco_residencia', 6),
('cep_residencia', 6)])
row10 = sapl.layout.to_row(
[('municipio_residencia', 12)])
row11 = sapl.layout.to_row(
[('telefone_residencia', 6),
('fax_residencia', 6)])
row12 = sapl.layout.to_row(
[('locais_atuacao', 12)])
row13 = sapl.layout.to_row(
[('fotografia', 12)])
row14 = sapl.layout.to_row(
[('biografia', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Cadastro do Parlamentar',
row1, row2, row3, row4, row5,
row6, row7, row8, row9, row10,
row11, row12, row13,
HTML("""{% if form.fotografia.value %}
<img class="img-responsive" width="225" height="300"
src="{{ MEDIA_URL }}{{ form.fotografia.value }}">
<br /><br />
<input type="submit"
name="remover"
id="remover"
class="button primary"
value="Remover Foto"/>
{% endif %}""", ),
row14,
form_actions())
)
super(ParlamentaresForm, self).__init__(
*args, **kwargs)
class ParlamentaresEditForm(ParlamentaresForm):
def __init__(self, *args, **kwargs):
super(ParlamentaresEditForm, self).__init__(
*args, **kwargs)
self.helper.layout[0][-1:] = form_actions(more=[
HTML('&nbsp;'),
Submit('excluir', 'Excluir',
css_class='btn btn-primary')])
class MandatoForm(ModelForm):
class Meta:
model = Mandato
fields = ['legislatura',
'coligacao',
'votos_recebidos',
'data_fim_mandato',
'data_expedicao_diploma',
'observacao']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('legislatura', 4),
('coligacao', 4),
('votos_recebidos', 4)])
row2 = sapl.layout.to_row(
[('data_fim_mandato', 6),
('data_expedicao_diploma', 6)])
row3 = sapl.layout.to_row(
[('observacao', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Adicionar Mandato', row1, row2, row3,
form_actions())
)
super(MandatoForm, self).__init__(
*args, **kwargs)
class MandatoEditForm(MandatoForm):
def __init__(self, *args, **kwargs):
super(MandatoEditForm, self).__init__(
*args, **kwargs)
self.helper.layout[0][-1:] = form_actions(more=[
HTML('&nbsp;'),
Submit('excluir', 'Excluir',
css_class='btn btn-primary')])
class DependenteForm(ModelForm):
class Meta:
model = Dependente
fields = ['nome',
'data_nascimento',
'tipo',
'sexo',
'cpf',
'rg',
'titulo_eleitor']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('nome', 12)])
row2 = sapl.layout.to_row(
[('tipo', 4),
('sexo', 4),
('data_nascimento', 4)])
row3 = sapl.layout.to_row(
[('cpf', 4),
('rg', 4),
('titulo_eleitor', 4)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Cadastro de Dependentes',
row1, row2, row3,
form_actions())
)
super(DependenteForm, self).__init__(
*args, **kwargs)
class DependenteEditForm(DependenteForm):
def __init__(self, *args, **kwargs):
super(DependenteEditForm, self).__init__(
*args, **kwargs)
self.helper.layout[0][-1:] = form_actions(more=[
HTML('&nbsp;'),
Submit('excluir', 'Excluir',
css_class='btn btn-primary')])
class FiliacaoForm(ModelForm):
class Meta:
model = Filiacao
fields = ['partido',
'data',
'data_desfiliacao']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('partido', 4),
('data', 4),
('data_desfiliacao', 4)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Adicionar Filiação', row1,
form_actions())
)
super(FiliacaoForm, self).__init__(
*args, **kwargs)
class FiliacaoEditForm(FiliacaoForm):
def __init__(self, *args, **kwargs):
super(FiliacaoEditForm, self).__init__(
*args, **kwargs)
self.helper.layout[0][-1:] = form_actions(more=[
HTML('&nbsp;'),
Submit('excluir', 'Excluir',
css_class='btn btn-primary')])

325
parlamentares/views.py

@ -1,22 +1,19 @@
import os import os
from re import sub from re import sub
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Fieldset, Layout, Submit
from django import forms
from django.contrib import messages from django.contrib import messages
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.forms import ModelForm
from django.utils.html import strip_tags from django.utils.html import strip_tags
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from vanilla import GenericView from vanilla import GenericView
import sapl
from sapl.crud import build_crud from sapl.crud import build_crud
from sapl.layout import form_actions
from .forms import (DependenteEditForm, DependenteForm, FiliacaoEditForm,
FiliacaoForm, MandatoEditForm, MandatoForm,
ParlamentaresEditForm, ParlamentaresForm,
ParlamentaresListForm)
from .models import (CargoMesa, Coligacao, ComposicaoMesa, Dependente, from .models import (CargoMesa, Coligacao, ComposicaoMesa, Dependente,
Filiacao, Legislatura, Mandato, NivelInstrucao, Filiacao, Legislatura, Mandato, NivelInstrucao,
Parlamentar, Partido, SessaoLegislativa, SituacaoMilitar, Parlamentar, Partido, SessaoLegislativa, SituacaoMilitar,
@ -149,10 +146,6 @@ tipo_militar_crud = build_crud(
]) ])
class ParlamentaresListForm(forms.Form):
periodo = forms.CharField()
class ParlamentaresView(GenericView): class ParlamentaresView(GenericView):
template_name = "parlamentares/parlamentares_list.html" template_name = "parlamentares/parlamentares_list.html"
@ -227,182 +220,6 @@ class ParlamentaresView(GenericView):
'parlamentares': parlamentares}) 'parlamentares': parlamentares})
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in self]))
class ParlamentaresForm (ModelForm):
ativo = forms.TypedChoiceField(
coerce=lambda x: x == 'True',
choices=((True, 'Sim'), (False, 'Não')),
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer
)
)
cpf = forms.CharField(label='C.P.F',
required=False,
widget=forms.TextInput(
attrs={'class': 'cpf'}))
rg = forms.CharField(label='R.G.',
required=False,
widget=forms.TextInput(
attrs={'class': 'rg'}))
titulo_eleitor = forms.CharField(label='Título de Eleitor',
required=False,
widget=forms.TextInput(
attrs={'class': 'titulo_eleitor'}))
telefone = forms.CharField(label='Telefone',
required=False,
widget=forms.TextInput(
attrs={'class': 'telefone'}))
fax = forms.CharField(label='Fax',
required=False,
widget=forms.TextInput(
attrs={'class': 'telefone'}))
cep_residencia = forms.CharField(label='CEP',
required=False,
widget=forms.TextInput(
attrs={'class': 'cep'}))
telefone_residencia = forms.CharField(label='Telefone',
required=False,
widget=forms.TextInput(
attrs={'class': 'telefone'}))
fax_residencia = forms.CharField(label='Fax',
required=False,
widget=forms.TextInput(
attrs={'class': 'telefone'}))
fotografia = forms.ImageField(label='Fotografia',
required=False,
widget=forms.FileInput
)
class Meta:
model = Parlamentar
fields = ['nome_parlamentar',
'ativo',
'nome_completo',
'nivel_instrucao',
'sexo',
'cpf',
'rg',
'titulo_eleitor',
'data_nascimento',
'situacao_militar',
'profissao',
'endereco_web',
'email',
'numero_gab_parlamentar',
'telefone',
'fax',
'endereco_residencia',
'cep_residencia',
'municipio_residencia',
'telefone_residencia',
'fax_residencia',
'locais_atuacao',
'fotografia',
'biografia']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('nome_parlamentar', 8), ('ativo', 4)])
row2 = sapl.layout.to_row(
[('nome_completo', 12)])
row3 = sapl.layout.to_row(
[('nivel_instrucao', 4),
('sexo', 4),
('data_nascimento', 4)])
row4 = sapl.layout.to_row(
[('cpf', 4),
('rg', 4),
('titulo_eleitor', 4)])
row5 = sapl.layout.to_row(
[('situacao_militar', 6),
('profissao', 6)])
row6 = sapl.layout.to_row(
[('endereco_web', 12)])
row7 = sapl.layout.to_row(
[('email', 12)])
row8 = sapl.layout.to_row(
[('numero_gab_parlamentar', 4),
('telefone', 4),
('fax', 4)])
row9 = sapl.layout.to_row(
[('endereco_residencia', 6),
('cep_residencia', 6)])
row10 = sapl.layout.to_row(
[('municipio_residencia', 12)])
row11 = sapl.layout.to_row(
[('telefone_residencia', 6),
('fax_residencia', 6)])
row12 = sapl.layout.to_row(
[('locais_atuacao', 12)])
row13 = sapl.layout.to_row(
[('fotografia', 12)])
row14 = sapl.layout.to_row(
[('biografia', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Cadastro do Parlamentar',
row1, row2, row3, row4, row5,
row6, row7, row8, row9, row10,
row11, row12, row13,
HTML("""{% if form.fotografia.value %}
<img class="img-responsive" width="225" height="300"
src="{{ MEDIA_URL }}{{ form.fotografia.value }}">
<br /><br />
<input type="submit"
name="remover"
id="remover"
class="button primary"
value="Remover Foto"/>
{% endif %}""", ),
row14,
form_actions())
)
super(ParlamentaresForm, self).__init__(
*args, **kwargs)
class ParlamentaresEditForm(ParlamentaresForm):
def __init__(self, *args, **kwargs):
super(ParlamentaresEditForm, self).__init__(
*args, **kwargs)
self.helper.layout[0][-1:] = form_actions(more=[
HTML('&nbsp;'),
Submit('excluir', 'Excluir',
css_class='btn btn-primary')])
class ParlamentaresCadastroView(FormMixin, GenericView): class ParlamentaresCadastroView(FormMixin, GenericView):
template_name = "parlamentares/parlamentares_cadastro.html" template_name = "parlamentares/parlamentares_cadastro.html"
@ -483,56 +300,6 @@ class ParlamentaresEditarView(FormMixin, GenericView):
return self.render_to_response({'form': form}) return self.render_to_response({'form': form})
class DependenteForm(ModelForm):
class Meta:
model = Dependente
fields = ['nome',
'data_nascimento',
'tipo',
'sexo',
'cpf',
'rg',
'titulo_eleitor']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('nome', 12)])
row2 = sapl.layout.to_row(
[('tipo', 4),
('sexo', 4),
('data_nascimento', 4)])
row3 = sapl.layout.to_row(
[('cpf', 4),
('rg', 4),
('titulo_eleitor', 4)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Cadastro de Dependentes',
row1, row2, row3,
form_actions())
)
super(DependenteForm, self).__init__(
*args, **kwargs)
class DependenteEditForm(DependenteForm):
def __init__(self, *args, **kwargs):
super(DependenteEditForm, self).__init__(
*args, **kwargs)
self.helper.layout[0][-1:] = form_actions(more=[
HTML('&nbsp;'),
Submit('excluir', 'Excluir',
css_class='btn btn-primary')])
class ParlamentaresDependentesView(FormMixin, GenericView): class ParlamentaresDependentesView(FormMixin, GenericView):
template_name = "parlamentares/parlamentares_dependentes.html" template_name = "parlamentares/parlamentares_dependentes.html"
@ -732,43 +499,6 @@ class MesaDiretoraView(FormMixin, GenericView):
}) })
class FiliacaoForm(ModelForm):
class Meta:
model = Filiacao
fields = ['partido',
'data',
'data_desfiliacao']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('partido', 4),
('data', 4),
('data_desfiliacao', 4)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Adicionar Filiação', row1,
form_actions())
)
super(FiliacaoForm, self).__init__(
*args, **kwargs)
class FiliacaoEditForm(FiliacaoForm):
def __init__(self, *args, **kwargs):
super(FiliacaoEditForm, self).__init__(
*args, **kwargs)
self.helper.layout[0][-1:] = form_actions(more=[
HTML('&nbsp;'),
Submit('excluir', 'Excluir',
css_class='btn btn-primary')])
class FiliacaoView(FormMixin, GenericView): class FiliacaoView(FormMixin, GenericView):
template_name = "parlamentares/parlamentares_filiacao.html" template_name = "parlamentares/parlamentares_filiacao.html"
@ -1005,53 +735,6 @@ class FiliacaoEditView(FormMixin, GenericView):
).legislatura_id}) ).legislatura_id})
class MandatoForm(ModelForm):
class Meta:
model = Mandato
fields = ['legislatura',
'coligacao',
'votos_recebidos',
'data_fim_mandato',
'data_expedicao_diploma',
'observacao']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('legislatura', 4),
('coligacao', 4),
('votos_recebidos', 4)])
row2 = sapl.layout.to_row(
[('data_fim_mandato', 6),
('data_expedicao_diploma', 6)])
row3 = sapl.layout.to_row(
[('observacao', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Adicionar Mandato', row1, row2, row3,
form_actions())
)
super(MandatoForm, self).__init__(
*args, **kwargs)
class MandatoEditForm(MandatoForm):
def __init__(self, *args, **kwargs):
super(MandatoEditForm, self).__init__(
*args, **kwargs)
self.helper.layout[0][-1:] = form_actions(more=[
HTML('&nbsp;'),
Submit('excluir', 'Excluir',
css_class='btn btn-primary')])
class MandatoView(FormMixin, GenericView): class MandatoView(FormMixin, GenericView):
template_name = "parlamentares/parlamentares_mandato.html" template_name = "parlamentares/parlamentares_mandato.html"

410
protocoloadm/forms.py

@ -0,0 +1,410 @@
from datetime import date
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Field, Fieldset, Layout
from django import forms
from django.forms import ModelForm
from django.utils.safestring import mark_safe
import sapl
from materia.models import TipoMateriaLegislativa
from sapl.layout import form_actions
from .models import (Autor, DocumentoAcessorioAdministrativo,
TipoDocumentoAdministrativo, TramitacaoAdministrativo)
def get_range_anos():
return [('', 'Selecione')] \
+ [(year, year) for year in range(date.today().year, 1960, -1)]
TIPOS_PROTOCOLO = [('', 'Selecione'),
('0', 'Enviado'),
('1', 'Recebido')]
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in self]))
class ProtocoloForm(forms.Form):
YEARS = get_range_anos()
tipo_protocolo = forms.ChoiceField(required=False,
label='Tipo de Protocolo',
choices=TIPOS_PROTOCOLO,
widget=forms.Select(
attrs={'class': 'selector'}))
numero_protocolo = forms.CharField(
label='Número de Protocolo', required=False)
ano = forms.ChoiceField(required=False,
label='Ano',
choices=YEARS,
widget=forms.Select(
attrs={'class': 'selector'}))
inicial = forms.DateField(label='Data Inicial',
required=False,
widget=forms.TextInput(
attrs={'class': 'dateinput'}))
final = forms.DateField(label='Data Final', required=False,
widget=forms.TextInput(
attrs={'class': 'dateinput'}))
natureza_processo = forms.ChoiceField(required=False,
label='Natureza Processo',
choices=[
('0', 'Administrativo'),
('1', 'Legislativo'),
('', 'Ambos')],
# widget=forms.RadioSelect(
# renderer=HorizontalRadioRenderer)
)
tipo_documento = forms.ModelChoiceField(
label='Tipo de Documento',
required=False,
queryset=TipoDocumentoAdministrativo.objects.all(),
empty_label='Selecione',
)
interessado = forms.CharField(label='Interessado', required=False)
tipo_materia = forms.ModelChoiceField(
label='Tipo de Matéria',
required=False,
queryset=TipoMateriaLegislativa.objects.all(),
empty_label='Selecione',
)
autor = forms.ModelChoiceField(
label='Autor',
required=False,
queryset=Autor.objects.all().order_by('tipo'),
empty_label='Selecione',
)
assunto = forms.CharField(label='Assunto', required=False)
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('numero_protocolo', 6),
('ano', 6)])
row2 = sapl.layout.to_row(
[('inicial', 6),
('final', 6)])
row3 = sapl.layout.to_row(
[('tipo_documento', 4),
('tipo_protocolo', 4),
('tipo_materia', 4)])
row4 = sapl.layout.to_row(
[('interessado', 4),
('autor', 4),
('assunto', 4)])
row5 = sapl.layout.to_row(
[('natureza_processo', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(row1, row2,
row3, row4,
row5, form_actions(save_label='Pesquisar'))
super(ProtocoloForm, self).__init__(
*args, **kwargs)
class AnularProcoloAdmForm(forms.Form):
YEARS = get_range_anos()
numero_protocolo = forms.CharField(
label='Número de Protocolo', required=True)
ano_protocolo = forms.ChoiceField(required=False,
label='Ano',
choices=YEARS,
widget=forms.Select(
attrs={'class': 'selector'}))
justificativa_anulacao = forms.CharField(
widget=forms.Textarea, label='Motivo', required=True)
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('numero_protocolo', 6),
('ano_protocolo', 6)])
row2 = sapl.layout.to_row(
[('justificativa_anulacao', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Identificação do Protocolo',
row1,
row2,
HTML("&nbsp;"),
form_actions(save_label='Anular')
)
)
super(AnularProcoloAdmForm, self).__init__(
*args, **kwargs)
class ProtocoloDocumentForm(forms.Form):
NUMERACAO_CHOICES = [('1', 'Sequencial por Ano'),
('2', 'Sequencial Único')]
numeracao = forms.ChoiceField(required=True,
choices=NUMERACAO_CHOICES,
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer),
label='')
tipo_protocolo = forms.ChoiceField(required=True,
label='Tipo de Protocolo',
choices=TIPOS_PROTOCOLO[1:],
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer))
tipo_documento = forms.ModelChoiceField(
label='Tipo de Documento',
required=False,
queryset=TipoDocumentoAdministrativo.objects.all(),
empty_label='Selecione',
)
num_paginas = forms.CharField(label='Núm. Páginas', required=True)
assunto = forms.CharField(
widget=forms.Textarea, label='Assunto', required=True)
interessado = forms.CharField(required=True,
label='Interessado')
observacao = forms.CharField(required=True,
widget=forms.Textarea, label='Observação')
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('numeracao', 12)])
row2 = sapl.layout.to_row(
[('tipo_protocolo', 12)])
row3 = sapl.layout.to_row(
[('tipo_documento', 6),
('num_paginas', 6)])
row4 = sapl.layout.to_row(
[('assunto', 12)])
row5 = sapl.layout.to_row(
[('interessado', 12)])
row6 = sapl.layout.to_row(
[('observacao', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Protocolo - Opção de Numeração', row1),
Fieldset('Identificação de Documento',
row2,
row3,
row4,
row5,
row6,
HTML("&nbsp;"),
form_actions(save_label='Protocolar Documento')
)
)
super(ProtocoloDocumentForm, self).__init__(
*args, **kwargs)
class ProtocoloMateriaForm(forms.Form):
NUMERACAO_CHOICES = [('1', 'Sequencial por Ano'),
('2', 'Sequencial Único')]
numeracao = forms.ChoiceField(required=True,
choices=NUMERACAO_CHOICES,
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer),
label='')
tipo_protocolo = forms.ChoiceField(required=True,
label='Tipo de Protocolo',
choices=TIPOS_PROTOCOLO[1:],
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer))
tipo_materia = forms.ModelChoiceField(
label='Tipo de Matéria',
required=False,
queryset=TipoMateriaLegislativa.objects.all(),
empty_label='Selecione',
)
num_paginas = forms.CharField(label='Núm. Páginas', required=True)
ementa = forms.CharField(
widget=forms.Textarea, label='Ementa', required=True)
autor = forms.ModelChoiceField(
label='Autor',
required=False,
queryset=Autor.objects.all().order_by('tipo'),
empty_label='Selecione',
)
observacao = forms.CharField(required=True,
widget=forms.Textarea,
label='Observação')
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('numeracao', 12)])
row2 = sapl.layout.to_row(
[('tipo_materia', 6),
('num_paginas', 6)])
row3 = sapl.layout.to_row(
[('ementa', 12)])
row4 = sapl.layout.to_row(
[('autor', 12)])
row5 = sapl.layout.to_row(
[('observacao', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Protocolo - Opção de Numeração', row1),
Fieldset('Identificação da Matéria',
row2,
row3,
row4,
row5,
HTML("&nbsp;"),
form_actions(save_label='Protocolar Matéria')
)
)
super(ProtocoloMateriaForm, self).__init__(
*args, **kwargs)
class ProposicaoSimpleForm(forms.Form):
tipo = forms.CharField(label='Tipo',
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
materia = forms.CharField(label='Matéria',
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
data_envio = forms.DateField(label='Data Envio',
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'readonly': 'readonly'}))
data_recebimento = forms.DateField(label='Data Recebimento',
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'readonly': 'readonly'}))
descricao = forms.CharField(label='Descrição',
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
numero_proposicao = forms.CharField(label='Número',
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
# ano = forms.CharField(label='Ano',
# widget = forms.TextInput(
# attrs={'readonly':'readonly'}))
class DocumentoAcessorioAdministrativoForm(ModelForm):
data = forms.DateField(label=u'Data', input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(format='%d/%m/%Y'))
class Meta:
model = DocumentoAcessorioAdministrativo
fields = ['tipo',
'nome',
'data',
'autor',
'arquivo',
'assunto']
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Incluir Documento Acessório',
'tipo',
'nome',
'data',
'autor',
'arquivo',
'assunto',
form_actions()
)
)
super(DocumentoAcessorioAdministrativoForm, self).__init__(
*args, **kwargs)
class TramitacaoAdmForm(ModelForm):
data_tramitacao = forms.DateField(label=u'Data Tramitação',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_encaminhamento = forms.DateField(label=u'Data Encaminhamento',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_fim_prazo = forms.DateField(label=u'Data Fim Prazo',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
class Meta:
model = TramitacaoAdministrativo
fields = ['data_tramitacao',
'unidade_tramitacao_local',
'status',
'unidade_tramitacao_destino',
'data_encaminhamento',
'data_fim_prazo',
'texto',
'documento',
]
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Incluir Tramitação',
'data_tramitacao',
'unidade_tramitacao_local',
'status',
'unidade_tramitacao_destino',
'data_encaminhamento',
'data_fim_prazo',
'texto'),
Field('documento', type="hidden"),
form_actions()
)
super(TramitacaoAdmForm, self).__init__(
*args, **kwargs)

405
protocoloadm/views.py

@ -1,17 +1,13 @@
from datetime import date, datetime from datetime import date, datetime
from re import sub from re import sub
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Field, Fieldset, Layout
from django import forms from django import forms
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.db.models import Max from django.db.models import Max
from django.forms import ModelForm
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.shortcuts import redirect from django.shortcuts import redirect
from django.utils.html import strip_tags from django.utils.html import strip_tags
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import DetailView, ListView from django.views.generic import DetailView, ListView
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
@ -21,8 +17,10 @@ from vanilla import GenericView
import sapl import sapl
from materia.models import Proposicao, TipoMateriaLegislativa from materia.models import Proposicao, TipoMateriaLegislativa
from sapl.crud import build_crud from sapl.crud import build_crud
from sapl.layout import form_actions
from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm,
ProposicaoSimpleForm, ProtocoloDocumentForm, ProtocoloForm,
ProtocoloMateriaForm, TramitacaoAdmForm)
from .models import (Autor, DocumentoAcessorioAdministrativo, from .models import (Autor, DocumentoAcessorioAdministrativo,
DocumentoAdministrativo, Protocolo, DocumentoAdministrativo, Protocolo,
StatusTramitacaoAdministrativo, StatusTramitacaoAdministrativo,
@ -101,113 +99,6 @@ protocolo_materia_crud = build_crud(
]) ])
def get_range_anos():
return [('', 'Selecione')] \
+ [(year, year) for year in range(date.today().year, 1960, -1)]
TIPOS_PROTOCOLO = [('', 'Selecione'),
('0', 'Enviado'),
('1', 'Recebido')]
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in self]))
class ProtocoloForm(forms.Form):
YEARS = get_range_anos()
tipo_protocolo = forms.ChoiceField(required=False,
label='Tipo de Protocolo',
choices=TIPOS_PROTOCOLO,
widget=forms.Select(
attrs={'class': 'selector'}))
numero_protocolo = forms.CharField(
label='Número de Protocolo', required=False)
ano = forms.ChoiceField(required=False,
label='Ano',
choices=YEARS,
widget=forms.Select(
attrs={'class': 'selector'}))
inicial = forms.DateField(label='Data Inicial',
required=False,
widget=forms.TextInput(
attrs={'class': 'dateinput'}))
final = forms.DateField(label='Data Final', required=False,
widget=forms.TextInput(
attrs={'class': 'dateinput'}))
natureza_processo = forms.ChoiceField(required=False,
label='Natureza Processo',
choices=[
('0', 'Administrativo'),
('1', 'Legislativo'),
('', 'Ambos')],
# widget=forms.RadioSelect(
# renderer=HorizontalRadioRenderer)
)
tipo_documento = forms.ModelChoiceField(
label='Tipo de Documento',
required=False,
queryset=TipoDocumentoAdministrativo.objects.all(),
empty_label='Selecione',
)
interessado = forms.CharField(label='Interessado', required=False)
tipo_materia = forms.ModelChoiceField(
label='Tipo de Matéria',
required=False,
queryset=TipoMateriaLegislativa.objects.all(),
empty_label='Selecione',
)
autor = forms.ModelChoiceField(
label='Autor',
required=False,
queryset=Autor.objects.all().order_by('tipo'),
empty_label='Selecione',
)
assunto = forms.CharField(label='Assunto', required=False)
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('numero_protocolo', 6),
('ano', 6)])
row2 = sapl.layout.to_row(
[('inicial', 6),
('final', 6)])
row3 = sapl.layout.to_row(
[('tipo_documento', 4),
('tipo_protocolo', 4),
('tipo_materia', 4)])
row4 = sapl.layout.to_row(
[('interessado', 4),
('autor', 4),
('assunto', 4)])
row5 = sapl.layout.to_row(
[('natureza_processo', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(row1, row2, row3, row4, row5, form_actions(save_label='Pesquisar'))
super(ProtocoloForm, self).__init__(
*args, **kwargs)
class ProtocoloListView(FormMixin, ListView): class ProtocoloListView(FormMixin, ListView):
template_name = 'protocoloadm/protocolo_list.html' template_name = 'protocoloadm/protocolo_list.html'
context_object_name = 'protocolos' context_object_name = 'protocolos'
@ -303,41 +194,6 @@ class ProtocoloPesquisaView(FormMixin, GenericView):
return self.form_invalid(form) return self.form_invalid(form)
class AnularProcoloAdmForm(forms.Form):
YEARS = get_range_anos()
numero_protocolo = forms.CharField(
label='Número de Protocolo', required=True)
ano_protocolo = forms.ChoiceField(required=False,
label='Ano',
choices=YEARS,
widget=forms.Select(
attrs={'class': 'selector'}))
justificativa_anulacao = forms.CharField(
widget=forms.Textarea, label='Motivo', required=True)
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('numero_protocolo', 6),
('ano_protocolo', 6)])
row2 = sapl.layout.to_row(
[('justificativa_anulacao', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Identificação do Protocolo',
row1,
row2,
HTML("&nbsp;"),
form_actions(save_label='Anular')
)
)
super(AnularProcoloAdmForm, self).__init__(
*args, **kwargs)
def get_client_ip(request): def get_client_ip(request):
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
if x_forwarded_for: if x_forwarded_for:
@ -398,73 +254,6 @@ class AnularProtocoloAdmView(FormMixin, GenericView):
return self.form_invalid(form) return self.form_invalid(form)
class ProtocoloDocumentForm(forms.Form):
NUMERACAO_CHOICES = [('1', 'Sequencial por Ano'),
('2', 'Sequencial Único')]
numeracao = forms.ChoiceField(required=True,
choices=NUMERACAO_CHOICES,
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer),
label='')
tipo_protocolo = forms.ChoiceField(required=True,
label='Tipo de Protocolo',
choices=TIPOS_PROTOCOLO[1:],
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer))
tipo_documento = forms.ModelChoiceField(
label='Tipo de Documento',
required=False,
queryset=TipoDocumentoAdministrativo.objects.all(),
empty_label='Selecione',
)
num_paginas = forms.CharField(label='Núm. Páginas', required=True)
assunto = forms.CharField(
widget=forms.Textarea, label='Assunto', required=True)
interessado = forms.CharField(required=True,
label='Interessado')
observacao = forms.CharField(required=True,
widget=forms.Textarea, label='Observação')
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('numeracao', 12)])
row2 = sapl.layout.to_row(
[('tipo_protocolo', 12)])
row3 = sapl.layout.to_row(
[('tipo_documento', 6),
('num_paginas', 6)])
row4 = sapl.layout.to_row(
[('assunto', 12)])
row5 = sapl.layout.to_row(
[('interessado', 12)])
row6 = sapl.layout.to_row(
[('observacao', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Protocolo - Opção de Numeração', row1),
Fieldset('Identificação de Documento',
row2,
row3,
row4,
row5,
row6,
HTML("&nbsp;"),
form_actions(save_label='Protocolar Documento')
)
)
super(ProtocoloDocumentForm, self).__init__(
*args, **kwargs)
class ProtocoloDocumentoView(FormMixin, GenericView): class ProtocoloDocumentoView(FormMixin, GenericView):
template_name = "protocoloadm/protocolar_documento.html" template_name = "protocoloadm/protocolar_documento.html"
@ -513,75 +302,6 @@ class ProtocoloDocumentoView(FormMixin, GenericView):
return self.form_invalid(form) return self.form_invalid(form)
class ProtocoloMateriaForm(forms.Form):
NUMERACAO_CHOICES = [('1', 'Sequencial por Ano'),
('2', 'Sequencial Único')]
numeracao = forms.ChoiceField(required=True,
choices=NUMERACAO_CHOICES,
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer),
label='')
tipo_protocolo = forms.ChoiceField(required=True,
label='Tipo de Protocolo',
choices=TIPOS_PROTOCOLO[1:],
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer))
tipo_materia = forms.ModelChoiceField(
label='Tipo de Matéria',
required=False,
queryset=TipoMateriaLegislativa.objects.all(),
empty_label='Selecione',
)
num_paginas = forms.CharField(label='Núm. Páginas', required=True)
ementa = forms.CharField(
widget=forms.Textarea, label='Ementa', required=True)
autor = forms.ModelChoiceField(
label='Autor',
required=False,
queryset=Autor.objects.all().order_by('tipo'),
empty_label='Selecione',
)
observacao = forms.CharField(required=True,
widget=forms.Textarea,
label='Observação')
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('numeracao', 12)])
row2 = sapl.layout.to_row(
[('tipo_materia', 6),
('num_paginas', 6)])
row3 = sapl.layout.to_row(
[('ementa', 12)])
row4 = sapl.layout.to_row(
[('autor', 12)])
row5 = sapl.layout.to_row(
[('observacao', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Protocolo - Opção de Numeração', row1),
Fieldset('Identificação da Matéria',
row2,
row3,
row4,
row5,
HTML("&nbsp;"),
form_actions(save_label='Protocolar Matéria')
)
)
super(ProtocoloMateriaForm, self).__init__(
*args, **kwargs)
class ProtocoloMostrarView(TemplateView): class ProtocoloMostrarView(TemplateView):
template_name = "protocoloadm/protocolo_mostrar.html" template_name = "protocoloadm/protocolo_mostrar.html"
@ -678,35 +398,6 @@ class ProposicoesIncorporadasView(ListView):
status='I') status='I')
class ProposicaoSimpleForm(forms.Form):
tipo = forms.CharField(label='Tipo',
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
materia = forms.CharField(label='Matéria',
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
data_envio = forms.DateField(label='Data Envio',
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'readonly': 'readonly'}))
data_recebimento = forms.DateField(label='Data Recebimento',
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'readonly': 'readonly'}))
descricao = forms.CharField(label='Descrição',
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
numero_proposicao = forms.CharField(label='Número',
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
# ano = forms.CharField(label='Ano',
# widget = forms.TextInput(
# attrs={'readonly':'readonly'}))
class ProposicaoView(TemplateView): class ProposicaoView(TemplateView):
template_name = "protocoloadm/proposicoes.html" template_name = "protocoloadm/proposicoes.html"
@ -860,44 +551,11 @@ class DetailDocumentoAdministrativo(DetailView):
return reverse('pesq_doc_adm') return reverse('pesq_doc_adm')
class ModelFormDocumentoAcessorioAdministrativo(ModelForm):
data = forms.DateField(label=u'Data', input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(format='%d/%m/%Y'))
class Meta:
model = DocumentoAcessorioAdministrativo
fields = ['tipo',
'nome',
'data',
'autor',
'arquivo',
'assunto']
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Incluir Documento Acessório',
'tipo',
'nome',
'data',
'autor',
'arquivo',
'assunto',
form_actions()
)
)
super(ModelFormDocumentoAcessorioAdministrativo, self).__init__(
*args, **kwargs)
class DocumentoAcessorioAdministrativoView(FormMixin, GenericView): class DocumentoAcessorioAdministrativoView(FormMixin, GenericView):
template_name = "protocoloadm/documento_acessorio_administrativo.html" template_name = "protocoloadm/documento_acessorio_administrativo.html"
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
form = ModelFormDocumentoAcessorioAdministrativo() form = DocumentoAcessorioAdministrativoForm()
doc = DocumentoAdministrativo.objects.get( doc = DocumentoAdministrativo.objects.get(
id=kwargs['pk']) id=kwargs['pk'])
doc_ace_null = '' doc_ace_null = ''
@ -915,7 +573,7 @@ class DocumentoAcessorioAdministrativoView(FormMixin, GenericView):
'form': form}) 'form': form})
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = ModelFormDocumentoAcessorioAdministrativo(request.POST) form = DocumentoAcessorioAdministrativoForm(request.POST)
if form.is_valid(): if form.is_valid():
doc_acessorio = DocumentoAcessorioAdministrativo() doc_acessorio = DocumentoAcessorioAdministrativo()
doc_acessorio.tipo = form.cleaned_data['tipo'] doc_acessorio.tipo = form.cleaned_data['tipo']
@ -951,59 +609,6 @@ class TramitacaoAdmView(FormMixin, GenericView):
'tramitacoes': tramitacoes}) 'tramitacoes': tramitacoes})
class TramitacaoAdmForm(ModelForm):
data_tramitacao = forms.DateField(label=u'Data Tramitação',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_encaminhamento = forms.DateField(label=u'Data Encaminhamento',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_fim_prazo = forms.DateField(label=u'Data Fim Prazo',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
class Meta:
model = TramitacaoAdministrativo
fields = ['data_tramitacao',
'unidade_tramitacao_local',
'status',
'unidade_tramitacao_destino',
'data_encaminhamento',
'data_fim_prazo',
'texto',
'documento',
]
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Incluir Tramitação',
'data_tramitacao',
'unidade_tramitacao_local',
'status',
'unidade_tramitacao_destino',
'data_encaminhamento',
'data_fim_prazo',
'texto'),
Field('documento', type="hidden"),
form_actions()
)
super(TramitacaoAdmForm, self).__init__(
*args, **kwargs)
class TramitacaoAdmIncluirView(FormMixin, GenericView): class TramitacaoAdmIncluirView(FormMixin, GenericView):
template_name = "protocoloadm/tramitacao_incluir.html" template_name = "protocoloadm/tramitacao_incluir.html"

2
relatorios/views.py

@ -3,8 +3,8 @@ from datetime import datetime
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from django.http import HttpResponse from django.http import HttpResponse
from base.forms import ESTADOS
from base.models import CasaLegislativa from base.models import CasaLegislativa
from base.views import ESTADOS
from comissoes.models import Comissao from comissoes.models import Comissao
from materia.models import (Autor, Autoria, MateriaLegislativa, Numeracao, from materia.models import (Autor, Autoria, MateriaLegislativa, Numeracao,
Tramitacao, UnidadeTramitacao) Tramitacao, UnidadeTramitacao)

159
sessao/forms.py

@ -0,0 +1,159 @@
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Column, Fieldset, Layout
from django import forms
from django.forms import ModelForm
import sapl
from sapl.layout import form_actions
from .models import AcompanharMateria, SessaoPlenaria
class PresencaForm(forms.Form):
presenca = forms.CharField(required=False, initial=False)
parlamentar = forms.CharField(required=False, max_length=20)
class VotacaoNominalForm(forms.Form):
pass
class ListMateriaForm(forms.Form):
error_message = forms.CharField(required=False, label='votacao_aberta')
class MateriaOrdemDiaForm(forms.Form):
data_sessao = forms.CharField(required=True, label='Data da Sessão')
numero_ordem = forms.IntegerField(required=True, label='Número Ordem')
tipo_votacao = forms.IntegerField(required=True, label='Tipo Votação')
tipo_sessao = forms.IntegerField(required=True, label='Tipo da Sessão')
ano_materia = forms.IntegerField(required=True, label='Ano Matéria')
numero_materia = forms.IntegerField(required=True, label='Número Matéria')
tipo_materia = forms.IntegerField(required=True, label='Tipo Matéria')
observacao = forms.CharField(required=False, label='Ementa')
error_message = forms.CharField(required=False, label='Matéria')
class OradorForm(forms.Form):
numero_ordem = forms.IntegerField(
required=True,
label='Ordem de pronunciamento')
parlamentar = forms.CharField(required=False, max_length=20)
url_discurso = forms.CharField(required=False, max_length=100)
class OradorDeleteForm(forms.Form):
pass
class MesaForm(forms.Form):
parlamentar = forms.IntegerField(required=True)
cargo = forms.IntegerField(required=True)
class ExpedienteForm(forms.Form):
conteudo = forms.CharField(required=False, widget=forms.Textarea)
class VotacaoForm(forms.Form):
votos_sim = forms.CharField(required=True, label='Sim')
votos_nao = forms.CharField(required=True, label='Não')
abstencoes = forms.CharField(required=True, label='Abstenções')
total_votos = forms.CharField(required=False, label='total')
class VotacaoEditForm(forms.Form):
pass
class AcompanharMateriaForm(ModelForm):
class Meta:
model = AcompanharMateria
fields = ['email']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row([('email', 10)])
row1.append(
Column(form_actions(save_label='Cadastrar'), css_class='col-md-2')
)
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Acompanhamento de Matéria por e-mail', row1
)
)
super(AcompanharMateriaForm, self).__init__(*args, **kwargs)
class SessaoForm(ModelForm):
hora_inicio = forms.CharField(label='Horário Inicio',
required=True,
widget=forms.TextInput(
attrs={'class': 'hora'}))
hora_fim = forms.CharField(label='Horário Fim',
required=True,
widget=forms.TextInput(
attrs={'class': 'hora'}))
class Meta:
model = SessaoPlenaria
fields = ['numero',
'tipo',
'legislatura',
'sessao_legislativa',
'data_inicio',
'hora_inicio',
'iniciada',
'data_fim',
'hora_fim',
'finalizada',
'upload_pauta',
'upload_ata',
'url_audio',
'url_video']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('numero', 3),
('tipo', 3),
('legislatura', 3),
('sessao_legislativa', 3)])
row2 = sapl.layout.to_row(
[('data_inicio', 4),
('hora_inicio', 4),
('iniciada', 4)])
row3 = sapl.layout.to_row(
[('data_fim', 4),
('hora_fim', 4),
('finalizada', 4)])
row4 = sapl.layout.to_row(
[('upload_pauta', 6),
('upload_ata', 6)])
row5 = sapl.layout.to_row(
[('url_audio', 6),
('url_video', 6)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Dados Básicos',
row1,
row2,
row3,
row4,
row5,
form_actions()
)
)
super(SessaoForm, self).__init__(*args, **kwargs)

167
sessao/views.py

@ -1,12 +1,8 @@
from datetime import datetime from datetime import datetime
from re import sub from re import sub
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Column, Fieldset, Layout
from django import forms
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.forms import ModelForm
from django.forms.util import ErrorList from django.forms.util import ErrorList
from django.utils.html import strip_tags from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
@ -20,9 +16,12 @@ from materia.models import (Autoria, DocumentoAcessorio,
from norma.models import NormaJuridica from norma.models import NormaJuridica
from parlamentares.models import Parlamentar from parlamentares.models import Parlamentar
from sapl.crud import build_crud from sapl.crud import build_crud
from sapl.layout import form_actions
from sessao.serializers import SessaoPlenariaSerializer from sessao.serializers import SessaoPlenariaSerializer
from .forms import (AcompanharMateriaForm, ExpedienteForm, ListMateriaForm,
MateriaOrdemDiaForm, MesaForm, OradorDeleteForm,
OradorForm, PresencaForm, SessaoForm, VotacaoEditForm,
VotacaoForm, VotacaoNominalForm)
from .models import (AcompanharMateria, CargoMesa, ExpedienteMateria, from .models import (AcompanharMateria, CargoMesa, ExpedienteMateria,
ExpedienteSessao, IntegranteMesa, MateriaLegislativa, ExpedienteSessao, IntegranteMesa, MateriaLegislativa,
Orador, OradorExpediente, OrdemDia, PresencaOrdemDia, Orador, OradorExpediente, OrdemDia, PresencaOrdemDia,
@ -104,11 +103,6 @@ registro_votacao_crud = build_crud(
]) ])
class PresencaForm(forms.Form):
presenca = forms.CharField(required=False, initial=False)
parlamentar = forms.CharField(required=False, max_length=20)
class PresencaView(FormMixin, sessao_crud.CrudDetailView): class PresencaView(FormMixin, sessao_crud.CrudDetailView):
template_name = 'sessao/presenca.html' template_name = 'sessao/presenca.html'
form_class = PresencaForm form_class = PresencaForm
@ -219,10 +213,6 @@ class PresencaOrdemDiaView(FormMixin, sessao_crud.CrudDetailView):
return reverse('sessaoplenaria:presencaordemdia', kwargs={'pk': pk}) return reverse('sessaoplenaria:presencaordemdia', kwargs={'pk': pk})
class ListMateriaForm(forms.Form):
error_message = forms.CharField(required=False, label='votacao_aberta')
class ListMateriaOrdemDiaView(sessao_crud.CrudDetailView): class ListMateriaOrdemDiaView(sessao_crud.CrudDetailView):
template_name = 'sessao/materia_ordemdia_list.html' template_name = 'sessao/materia_ordemdia_list.html'
form_class = ListMateriaForm form_class = ListMateriaForm
@ -426,18 +416,6 @@ class ListExpedienteOrdemDiaView(sessao_crud.CrudDetailView):
return self.get(self, request, args, kwargs) return self.get(self, request, args, kwargs)
class MateriaOrdemDiaForm(forms.Form):
data_sessao = forms.CharField(required=True, label='Data da Sessão')
numero_ordem = forms.IntegerField(required=True, label='Número Ordem')
tipo_votacao = forms.IntegerField(required=True, label='Tipo Votação')
tipo_sessao = forms.IntegerField(required=True, label='Tipo da Sessão')
ano_materia = forms.IntegerField(required=True, label='Ano Matéria')
numero_materia = forms.IntegerField(required=True, label='Número Matéria')
tipo_materia = forms.IntegerField(required=True, label='Tipo Matéria')
observacao = forms.CharField(required=False, label='Ementa')
error_message = forms.CharField(required=False, label='Matéria')
class MateriaOrdemDiaView(FormMixin, sessao_crud.CrudDetailView): class MateriaOrdemDiaView(FormMixin, sessao_crud.CrudDetailView):
template_name = 'sessao/materia_ordemdia.html' template_name = 'sessao/materia_ordemdia.html'
form_class = MateriaOrdemDiaForm form_class = MateriaOrdemDiaForm
@ -761,18 +739,6 @@ class EditExpedienteOrdemDiaView(FormMixin, sessao_crud.CrudDetailView):
kwargs={'pk': pk}) kwargs={'pk': pk})
class OradorForm(forms.Form):
numero_ordem = forms.IntegerField(
required=True,
label='Ordem de pronunciamento')
parlamentar = forms.CharField(required=False, max_length=20)
url_discurso = forms.CharField(required=False, max_length=100)
class OradorDeleteForm(forms.Form):
pass
class OradorExpedienteDelete(FormMixin, sessao_crud.CrudDetailView): class OradorExpedienteDelete(FormMixin, sessao_crud.CrudDetailView):
template_name = 'sessao/delete_orador.html' template_name = 'sessao/delete_orador.html'
form_class = OradorDeleteForm form_class = OradorDeleteForm
@ -928,11 +894,6 @@ class OradorExpedienteView(FormMixin, sessao_crud.CrudDetailView):
return reverse('sessaoplenaria:oradorexpediente', kwargs={'pk': pk}) return reverse('sessaoplenaria:oradorexpediente', kwargs={'pk': pk})
class MesaForm(forms.Form):
parlamentar = forms.IntegerField(required=True)
cargo = forms.IntegerField(required=True)
class MesaView(FormMixin, sessao_crud.CrudDetailView): class MesaView(FormMixin, sessao_crud.CrudDetailView):
template_name = 'sessao/mesa.html' template_name = 'sessao/mesa.html'
form_class = MesaForm form_class = MesaForm
@ -1198,10 +1159,6 @@ class ResumoView(FormMixin, sessao_crud.CrudDetailView):
return self.render_to_response(context) return self.render_to_response(context)
class ExpedienteForm(forms.Form):
conteudo = forms.CharField(required=False, widget=forms.Textarea)
class ExpedienteView(FormMixin, sessao_crud.CrudDetailView): class ExpedienteView(FormMixin, sessao_crud.CrudDetailView):
template_name = 'sessao/expediente.html' template_name = 'sessao/expediente.html'
form_class = ExpedienteForm form_class = ExpedienteForm
@ -1419,17 +1376,6 @@ class ExplicacaoEdit(FormMixin, sessao_crud.CrudDetailView):
return reverse('sessaoplenaria:explicacao', kwargs={'pk': pk}) return reverse('sessaoplenaria:explicacao', kwargs={'pk': pk})
class VotacaoForm(forms.Form):
votos_sim = forms.CharField(required=True, label='Sim')
votos_nao = forms.CharField(required=True, label='Não')
abstencoes = forms.CharField(required=True, label='Abstenções')
total_votos = forms.CharField(required=False, label='total')
class VotacaoEdit(forms.Form):
pass
class VotacaoEditView(FormMixin, sessao_crud.CrudDetailView): class VotacaoEditView(FormMixin, sessao_crud.CrudDetailView):
''' '''
@ -1441,7 +1387,7 @@ class VotacaoEditView(FormMixin, sessao_crud.CrudDetailView):
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
form = VotacaoEdit(request.POST) form = VotacaoEditForm(request.POST)
materia_id = kwargs['oid'] materia_id = kwargs['oid']
ordem_id = kwargs['mid'] ordem_id = kwargs['mid']
@ -1621,10 +1567,6 @@ class VotacaoView(FormMixin, sessao_crud.CrudDetailView):
kwargs={'pk': pk}) kwargs={'pk': pk})
class VotacaoNominalForm(forms.Form):
pass
class VotacaoNominalView(FormMixin, sessao_crud.CrudDetailView): class VotacaoNominalView(FormMixin, sessao_crud.CrudDetailView):
template_name = 'sessao/votacao/nominal.html' template_name = 'sessao/votacao/nominal.html'
@ -1790,7 +1732,7 @@ class VotacaoNominalEditView(FormMixin, sessao_crud.CrudDetailView):
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
form = VotacaoEdit(request.POST) form = VotacaoEditForm(request.POST)
materia_id = kwargs['oid'] materia_id = kwargs['oid']
ordem_id = kwargs['mid'] ordem_id = kwargs['mid']
@ -1992,7 +1934,7 @@ class VotacaoNominalExpedienteEditView(FormMixin, sessao_crud.CrudDetailView):
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
form = VotacaoEdit(request.POST) form = VotacaoEditForm(request.POST)
materia_id = kwargs['oid'] materia_id = kwargs['oid']
expediente_id = kwargs['mid'] expediente_id = kwargs['mid']
@ -2208,7 +2150,7 @@ class VotacaoExpedienteEditView(FormMixin, sessao_crud.CrudDetailView):
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
form = VotacaoEdit(request.POST) form = VotacaoEditForm(request.POST)
materia_id = kwargs['oid'] materia_id = kwargs['oid']
expediente_id = kwargs['mid'] expediente_id = kwargs['mid']
@ -2347,76 +2289,6 @@ class PautaSessaoDetailView(sessao_crud.CrudDetailView):
return self.render_to_response(context) return self.render_to_response(context)
class SessaoForm(ModelForm):
hora_inicio = forms.CharField(label='Horário Inicio',
required=True,
widget=forms.TextInput(
attrs={'class': 'hora'}))
hora_fim = forms.CharField(label='Horário Fim',
required=True,
widget=forms.TextInput(
attrs={'class': 'hora'}))
class Meta:
model = SessaoPlenaria
fields = ['numero',
'tipo',
'legislatura',
'sessao_legislativa',
'data_inicio',
'hora_inicio',
'iniciada',
'data_fim',
'hora_fim',
'finalizada',
'upload_pauta',
'upload_ata',
'url_audio',
'url_video']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
[('numero', 3),
('tipo', 3),
('legislatura', 3),
('sessao_legislativa', 3)])
row2 = sapl.layout.to_row(
[('data_inicio', 4),
('hora_inicio', 4),
('iniciada', 4)])
row3 = sapl.layout.to_row(
[('data_fim', 4),
('hora_fim', 4),
('finalizada', 4)])
row4 = sapl.layout.to_row(
[('upload_pauta', 6),
('upload_ata', 6)])
row5 = sapl.layout.to_row(
[('url_audio', 6),
('url_video', 6)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Dados Básicos',
row1,
row2,
row3,
row4,
row5,
form_actions()
)
)
super(SessaoForm, self).__init__(*args, **kwargs)
class SessaoCadastroView(FormMixin, sessao_crud.CrudDetailView): class SessaoCadastroView(FormMixin, sessao_crud.CrudDetailView):
template_name = "sessao/sessao_cadastro.html" template_name = "sessao/sessao_cadastro.html"
@ -2492,29 +2364,6 @@ class PautaOrdemDetail(sessao_crud.CrudDetailView):
'tramitacao': tramitacao}) 'tramitacao': tramitacao})
class AcompanharMateriaForm(ModelForm):
class Meta:
model = AcompanharMateria
fields = ['email']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row([('email', 10)])
row1.append(
Column(form_actions(save_label='Cadastrar'), css_class='col-md-2')
)
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Acompanhamento de Matéria por e-mail', row1
)
)
super(AcompanharMateriaForm, self).__init__(*args, **kwargs)
class AcompanharMateriaView(FormMixin, sessao_crud.CrudDetailView): class AcompanharMateriaView(FormMixin, sessao_crud.CrudDetailView):
template_name = "sessao/pauta/acompanhar_materia.html" template_name = "sessao/pauta/acompanhar_materia.html"

Loading…
Cancel
Save