Browse Source

Add form to Proposicao

pull/11/merge
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
c7341b476f
  1. 20
      materia/migrations/0011_proposicao_texto_original.py
  2. 9
      materia/models.py
  3. 18
      materia/urls.py
  4. 94
      materia/views.py
  5. 1
      painel/views.py
  6. 19
      parlamentares/migrations/0007_auto_20151123_1258.py
  7. 6
      templates/materia/proposicao.html

20
materia/migrations/0011_proposicao_texto_original.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import materia.models
class Migration(migrations.Migration):
dependencies = [
('materia', '0010_auto_20151117_1551'),
]
operations = [
migrations.AddField(
model_name='proposicao',
name='texto_original',
field=models.FileField(upload_to=materia.models.texto_upload_path, verbose_name='Texto Original (PDF)', blank=True, null=True),
),
]

9
materia/models.py

@ -425,7 +425,6 @@ class TipoProposicao(models.Model):
class Proposicao(models.Model):
materia = models.ForeignKey(MateriaLegislativa, blank=True, null=True)
autor = models.ForeignKey(Autor)
tipo = models.ForeignKey(TipoProposicao, verbose_name=_('Tipo'))
# XXX data_envio was not null, but actual data said otherwise!!!
@ -443,9 +442,7 @@ class Proposicao(models.Model):
verbose_name=_('Justificativa da Devolução'))
numero_proposicao = models.PositiveIntegerField(
blank=True, null=True, verbose_name=_('Número'))
# ind_enviado and ind_devolvido collapsed as char field (status)
status = models.CharField(blank=True,
null=True,
max_length=1,
@ -453,12 +450,16 @@ class Proposicao(models.Model):
('D', 'Devolvida'),
('I', 'Incorporada')),
verbose_name=_('Status Proposição'))
# mutually exclusive (depend on tipo.materia_ou_documento)
materia = models.ForeignKey(
MateriaLegislativa, blank=True, null=True, verbose_name=_('Matéria'))
documento = models.ForeignKey(
DocumentoAcessorio, blank=True, null=True, verbose_name=_('Documento'))
texto_original = models.FileField(
blank=True,
null=True,
upload_to=texto_upload_path,
verbose_name=_('Texto Original (PDF)'))
class Meta:
verbose_name = _('Proposição')

18
materia/urls.py

@ -5,14 +5,14 @@ from materia.views import (AutoriaEditView, AutoriaView,
FormularioCadastroView, FormularioSimplificadoView,
LegislacaoCitadaEditView, LegislacaoCitadaView,
MateriaAnexadaEditView, MateriaAnexadaView,
NumeracaoEditView, NumeracaoView, RelatoriaEditView,
RelatoriaView, TramitacaoEditView, TramitacaoView,
autor_crud, materia_legislativa_crud, orgao_crud,
origem_crud, regime_tramitacao_crud,
status_tramitacao_crud, tipo_autor_crud,
tipo_documento_crud, tipo_fim_relatoria_crud,
tipo_materia_crud, tipo_proposicao_crud,
unidade_tramitacao_crud)
NumeracaoEditView, NumeracaoView, ProposicaoView,
RelatoriaEditView, RelatoriaView,
TramitacaoEditView, TramitacaoView, autor_crud,
materia_legislativa_crud, orgao_crud, origem_crud,
regime_tramitacao_crud, status_tramitacao_crud,
tipo_autor_crud, tipo_documento_crud,
tipo_fim_relatoria_crud, tipo_materia_crud,
tipo_proposicao_crud, unidade_tramitacao_crud)
urlpatterns = [
url(r'^sistema/proposicoes/tipo/', include(tipo_proposicao_crud.urls)),
@ -71,4 +71,6 @@ urlpatterns = [
AutoriaEditView.as_view(), name='autoria_edit'),
url(r'^materia/(?P<pk>\d+)/relatoria/(?P<id>\d+)/edit$',
RelatoriaEditView.as_view(), name='relatoria_edit'),
url(r'^materia/proposicao$',
ProposicaoView.as_view(), name='proposicao'),
]

94
materia/views.py

@ -217,6 +217,12 @@ tramitacao_crud = build_crud(
])
def get_tipos_proposicao():
return [('', 'Selecione')] \
+ [(t.id, t.descricao)
for t in TipoProposicao.objects.all()]
def get_tipos_materia():
return [('', 'Selecione')] \
+ [(t.id, t.sigla + ' - ' + t.descricao)
@ -1246,7 +1252,8 @@ class RelatoriaEditView(FormMixin, GenericView):
form = RelatoriaForm(request.POST)
materia = MateriaLegislativa.objects.get(id=kwargs['pk'])
relatoria = Relatoria.objects.get(id=kwargs['id'])
composicao = Composicao.objects.filter(comissao=relatoria.comissao).last()
composicao = Composicao.objects.filter(
comissao=relatoria.comissao).last()
parlamentares = composicao.participacao_set.all()
if form.is_valid():
@ -1688,3 +1695,88 @@ class AutoriaEditView(GenericView):
def get_success_url(self):
pk = self.kwargs['pk']
return reverse('autoria', kwargs={'pk': pk})
class ProposicaoForm(ModelForm):
tipo = forms.ChoiceField(required=True,
label='Tipo',
choices=get_tipos_proposicao(),
widget=forms.Select(
attrs={'class': 'selector'}))
descricao = forms.CharField(
label='Descrição', required=True)
tipo_materia = forms.ChoiceField(required=False,
label='Matéria Vinculada',
choices=get_tipos_materia(),
widget=forms.Select(
attrs={'class': 'selector'}))
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']
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Incluir Proposição',
HTML(
"<ul class='small-block-grid-1 medium-block-grid-1 large-block-grid-1'>"),
HTML("<li>"),
'tipo',
HTML("</li>"),
HTML("</ul>"),
HTML(
"<ul class='small-block-grid-1 medium-block-grid-1 large-block-grid-1'>"),
HTML("<li>"),
'descricao',
HTML("</li>"),
HTML("</ul>"),
HTML(
"<ul class='small-block-grid-3 medium-block-grid-3 large-block-grid-3'>"),
HTML("<li>"),
'tipo_materia',
HTML("</li>"),
HTML("<li>"),
'numero_materia',
HTML("</li>"),
HTML("<li>"),
'ano_materia',
HTML("</li>"),
HTML("</ul>"),
HTML(
"<ul class='small-block-grid-1 medium-block-grid-1 large-block-grid-1'>"),
HTML("<li>"),
'texto_original',
HTML("</li>"),
HTML("</ul>"),
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
),
)
super(ProposicaoForm, self).__init__(
*args, **kwargs)
class ProposicaoView(FormMixin, GenericView):
template_name = "materia/proposicao.html"
def get_success_url(self):
return reverse('proposicao')
def get(self, request, *args, **kwargs):
form = ProposicaoForm()
return self.render_to_response(
{'form': form})

1
painel/views.py

@ -71,7 +71,6 @@ def painel_votacao_view(request):
def get_dados_painel(request, pk):
# Sessão Plenária
sessao_plenaria_id = pk
sessao_plenaria = SessaoPlenaria.objects.get(id=sessao_plenaria_id)

19
parlamentares/migrations/0007_auto_20151123_1258.py

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('parlamentares', '0006_auto_20151119_1318'),
]
operations = [
migrations.AlterField(
model_name='parlamentar',
name='unidade_deliberativa',
field=models.BooleanField(),
),
]

6
templates/materia/proposicao.html

@ -0,0 +1,6 @@
{% extends "crud/form.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block detail_content %}
{% endblock %}
Loading…
Cancel
Save