diff --git a/base/views.py b/base/views.py
index 664b18680..58138cc16 100644
--- a/base/views.py
+++ b/base/views.py
@@ -1,6 +1,6 @@
import sapl
from crispy_forms.helper import FormHelper
-from crispy_forms.layout import ButtonHolder, HTML, Fieldset, Layout, Submit
+from crispy_forms.layout import ButtonHolder, Fieldset, Layout, Submit
from django import forms
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
@@ -11,8 +11,6 @@ from vanilla import GenericView
from .models import CasaLegislativa
-from sapl import settings
-
class HelpView(TemplateView):
# XXX treat non existing template as a 404!!!!
@@ -78,7 +76,7 @@ class CasaLegislativaTabelaAuxForm(ModelForm):
fax = forms.CharField(label='Fax',
required=False,
widget=forms.TextInput(
- attrs={'class': 'telefone'}))
+ attrs={'class': 'telefone'}))
class Meta:
@@ -137,10 +135,6 @@ class CasaLegislativaTabelaAuxForm(ModelForm):
row3,
row4,
row5,
- HTML("""{% if form.logotipo.value %}
-
- {% endif %}""", ),
row6,
row7,
row8,
@@ -168,7 +162,7 @@ class CasaLegislativaTableAuxView(FormMixin, GenericView):
return self.render_to_response({'form': form})
def post(self, request, *args, **kwargs):
- form = CasaLegislativaTabelaAuxForm(request.POST, request.FILES)
+ form = CasaLegislativaTabelaAuxForm(request.POST or request.FILES)
if form.is_valid():
try:
@@ -177,8 +171,13 @@ class CasaLegislativaTableAuxView(FormMixin, GenericView):
casa_save = form.save(commit=False)
else:
casa_save = CasaLegislativaTabelaAuxForm(
- request.POST, request.FILES, instance=casa).save(commit=False)
- casa_save.save()
+ request.POST, instance=casa)
+
+ if 'logotipo' in request.FILES:
+ casa_save.logotipo = request.FILES['logotipo']
+
+ casa_save.save()
+
return self.form_valid(form)
else:
return self.render_to_response({'form': form})
diff --git a/comissoes/urls.py b/comissoes/urls.py
index 452d52588..230142496 100644
--- a/comissoes/urls.py
+++ b/comissoes/urls.py
@@ -4,7 +4,7 @@ from comissoes.views import (ComissaoParlamentarEditView,
ComissaoParlamentarIncluirView, ComposicaoView,
MateriasView, ReunioesView, cargo_crud,
comissao_crud, periodo_composicao_crud,
- tipo_comissao_crud)
+ tipo_comissao_crud,CadastrarComissaoView)
comissao_url_patterns = comissao_crud.urlpatterns + [
url(r'^(?P\d+)/composicao$',
@@ -19,6 +19,8 @@ comissao_url_patterns = comissao_crud.urlpatterns + [
MateriasView.as_view(), name='materias'),
url(r'^(?P\d+)/reunioes$',
ReunioesView.as_view(), name='reunioes'),
+ url(r'^cadastrar-comissao$',
+ CadastrarComissaoView.as_view(), name='cadastrar_comissao'),
]
urlpatterns = [
diff --git a/comissoes/views.py b/comissoes/views.py
index 414acece3..732898e8d 100644
--- a/comissoes/views.py
+++ b/comissoes/views.py
@@ -1,5 +1,5 @@
from crispy_forms.helper import FormHelper
-from crispy_forms.layout import ButtonHolder, Fieldset, Layout, Submit
+from crispy_forms.layout import Layout, Fieldset, ButtonHolder, Submit, MultiField, Div, Field
from django import forms
from django.core.urlresolvers import reverse
from django.forms import ModelForm
@@ -7,6 +7,7 @@ from django.utils.translation import ugettext_lazy as _
from django.views.generic.edit import FormMixin
from vanilla import GenericView
+
import sapl
from parlamentares.models import Filiacao, Parlamentar
from sapl.crud import build_crud
@@ -35,7 +36,6 @@ tipo_comissao_crud = build_crud(
[('nome', 9), ('sigla', 3)],
[('dispositivo_regimental', 9), ('natureza', 3)]],
])
-
comissao_crud = build_crud(
Comissao, 'modulo_comissoes', [
@@ -65,6 +65,129 @@ 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(
+ '',
+ Fieldset(
+ 'Dados Básicos',
+ row1,
+ row2
+ ),
+ Fieldset(
+ 'Dados Complementares',
+ row3,
+ row4,
+ row5,
+ row6
+ ),
+ Fieldset(
+ 'Temporária',
+ row7,
+ row8
+ ),
+ ButtonHolder(
+ Submit('submit', 'Salvar',
+ css_class='button primary')
+ )
+ )
+ )
+ super(CadastrarComissaoForm, self).__init__(*args, **kwargs)
+
+
+class CadastrarComissaoView(FormMixin, GenericView):
+
+ template_name = "comissoes/cadastrar_comissao.html"
+
+ def get(self, request, *args, **kwargs):
+ form = CadastrarComissaoForm()
+
+ return self.render_to_response({'form': form})
+
+ def post(self, request, *args, **kwargs):
+ form = CadastrarComissaoForm(request.POST, request.FILES)
+
+ if form.is_valid():
+
+ form.save()
+
+ return self.form_valid(form)
+ else:
+ return self.render_to_response({'form': form})
+
+ def get_success_url(self):
+ return reverse('comissao:cadastrar_comissao')
+
+
+
class ComposicaoForm(forms.Form):
periodo = forms.CharField()
diff --git a/templates/comissoes/cadastrar_comissao.html b/templates/comissoes/cadastrar_comissao.html
new file mode 100644
index 000000000..3b59fbe57
--- /dev/null
+++ b/templates/comissoes/cadastrar_comissao.html
@@ -0,0 +1,8 @@
+{% extends "crud/detail.html" %}
+{% load i18n %}
+{% load crispy_forms_tags %}
+{% block actions %} {% endblock %}
+
+{% block detail_content %}
+ {% crispy form %}
+{% endblock detail_content %}