diff --git a/base/models.py b/base/models.py index dad967e61..aca2da222 100644 --- a/base/models.py +++ b/base/models.py @@ -1,6 +1,7 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ + def get_sessao_media_path(instance, subpath, filename): return './casa/%s/%s/%s' % (instance.codigo, subpath, filename) @@ -8,6 +9,7 @@ def get_sessao_media_path(instance, subpath, filename): def get_casa_media_path(instance, filename): return get_sessao_media_path(instance, 'Logotipo', filename) + class CasaLegislativa(models.Model): # TODO ajustar todos os max_length !!!! # cod_casa => id (pk) @@ -19,17 +21,24 @@ class CasaLegislativa(models.Model): cep = models.CharField(max_length=100, verbose_name=_('CEP')) municipio = models.CharField(max_length=100, verbose_name=_('Município')) uf = models.CharField(max_length=100, verbose_name=_('UF')) - telefone = models.CharField(max_length=100, blank=True, null=True, verbose_name=_('Telefone')) - fax = models.CharField(max_length=100, blank=True, null=True, verbose_name=_('Fax')) + telefone = models.CharField( + max_length=100, blank=True, null=True, verbose_name=_('Telefone')) + fax = models.CharField( + max_length=100, blank=True, null=True, verbose_name=_('Fax')) logotipo = models.ImageField( blank=True, null=True, upload_to=get_casa_media_path, verbose_name=_('Logotipo')) - endereco_web = models.CharField(max_length=100, blank=True, null=True, verbose_name=_('HomePage')) - email = models.CharField(max_length=100, blank=True, null=True, verbose_name=_('E-mail')) + endereco_web = models.CharField( + max_length=100, blank=True, null=True, verbose_name=_('HomePage')) + email = models.CharField( + max_length=100, blank=True, null=True, verbose_name=_('E-mail')) informacao_geral = models.CharField( - max_length=100, blank=True, null=True, verbose_name=_('Informação Geral')) + max_length=100, + blank=True, + null=True, + verbose_name=_('Informação Geral')) class Meta: verbose_name = _('Casa Legislativa') diff --git a/base/urls.py b/base/urls.py index 0f70ce5e0..47f66718f 100644 --- a/base/urls.py +++ b/base/urls.py @@ -1,8 +1,7 @@ from django.conf.urls import url from django.views.generic.base import TemplateView - -from .views import HelpView, CasaLegislativaTableAuxView +from .views import CasaLegislativaTableAuxView, HelpView urlpatterns = [ url(r'^sistema/', TemplateView.as_view(template_name='sistema.html')), @@ -11,5 +10,4 @@ urlpatterns = [ name='help_base'), url(r'^casa-legislativa$', CasaLegislativaTableAuxView.as_view(), name='casa_legislativa'), - ] diff --git a/base/views.py b/base/views.py index a466da1d1..a829d9b29 100644 --- a/base/views.py +++ b/base/views.py @@ -1,6 +1,5 @@ -import sapl from crispy_forms.helper import FormHelper -from crispy_forms.layout import ButtonHolder, HTML, Fieldset, Layout, Submit +from crispy_forms.layout import HTML, ButtonHolder, Fieldset, Layout, Submit from django import forms from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse @@ -9,9 +8,9 @@ from django.views.generic.base import TemplateView from django.views.generic.edit import FormMixin from vanilla import GenericView -from .models import CasaLegislativa +import sapl -from sapl import settings +from .models import CasaLegislativa class HelpView(TemplateView): @@ -60,9 +59,8 @@ class CasaLegislativaTabelaAuxForm(ModelForm): widget=forms.Select( attrs={'class': 'selector'})) - - informacao_geral = forms.CharField(widget=forms.Textarea, - label='Informação Geral', + informacao_geral = forms.CharField(widget=forms.Textarea, + label='Informação Geral', required=False) telefone = forms.CharField(label='Telefone', @@ -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: @@ -138,7 +136,7 @@ class CasaLegislativaTabelaAuxForm(ModelForm): row4, row5, HTML("""{% if form.logotipo.value %} - {% endif %}""", ), row6, @@ -177,11 +175,13 @@ class CasaLegislativaTableAuxView(FormMixin, GenericView): casa_save = form.save(commit=False) else: casa_save = CasaLegislativaTabelaAuxForm( - request.POST, request.FILES, instance=casa).save(commit=False) + request.POST, + request.FILES, + instance=casa).save(commit=False) casa_save.save() return self.form_valid(form) else: return self.render_to_response({'form': form}) def get_success_url(self): - return reverse('casa_legislativa') \ No newline at end of file + return reverse('casa_legislativa') diff --git a/comissoes/urls.py b/comissoes/urls.py index 230142496..36df60295 100644 --- a/comissoes/urls.py +++ b/comissoes/urls.py @@ -1,10 +1,11 @@ from django.conf.urls import include, url -from comissoes.views import (ComissaoParlamentarEditView, +from comissoes.views import (CadastrarComissaoView, + ComissaoParlamentarEditView, ComissaoParlamentarIncluirView, ComposicaoView, MateriasView, ReunioesView, cargo_crud, comissao_crud, periodo_composicao_crud, - tipo_comissao_crud,CadastrarComissaoView) + tipo_comissao_crud) comissao_url_patterns = comissao_crud.urlpatterns + [ url(r'^(?P\d+)/composicao$', diff --git a/comissoes/views.py b/comissoes/views.py index 0d6f9dbfd..d4a4e8f62 100644 --- a/comissoes/views.py +++ b/comissoes/views.py @@ -1,5 +1,5 @@ from crispy_forms.helper import FormHelper -from crispy_forms.layout import Layout, Fieldset, ButtonHolder, Submit, MultiField, Div, Field +from crispy_forms.layout import ButtonHolder, Fieldset, Layout, Submit from django import forms from django.core.urlresolvers import reverse from django.forms import ModelForm @@ -7,7 +7,6 @@ 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 @@ -66,7 +65,6 @@ comissao_crud = build_crud( class CadastrarComissaoForm(ModelForm): - class Meta: @@ -103,61 +101,60 @@ class CadastrarComissaoForm(ModelForm): row2 = sapl.layout.to_row( [('tipo', 3), ('data_criacao', 3), - ('unidade_deliberativa',3), - ('data_extincao',3)]) + ('unidade_deliberativa', 3), + ('data_extincao', 3)]) row3 = sapl.layout.to_row( - [('local_reuniao',4), - ('agenda_reuniao',4), - ('telefone_reuniao',4)]) - + [('local_reuniao', 4), + ('agenda_reuniao', 4), + ('telefone_reuniao', 4)]) row4 = sapl.layout.to_row( [('endereco_secretaria', 4), - ('telefone_secretaria', 4), - ('fax_secretaria', 4)]) + ('telefone_secretaria', 4), + ('fax_secretaria', 4)]) row5 = sapl.layout.to_row( - [('secretario',6), - ('email',6)]) + [('secretario', 6), + ('email', 6)]) row6 = sapl.layout.to_row( [('finalidade', 12)]) row7 = sapl.layout.to_row( [('apelido_temp', 9), - ('data_instalacao_temp',3)]) + ('data_instalacao_temp', 3)]) row8 = sapl.layout.to_row( - [('data_final_prevista_temp',4), - ('data_prorrogada_temp',4), - ('data_fim_comissao',4)]) + [('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 - ), - ButtonHolder( - Submit('submit', 'Salvar', - css_class='button primary') - ) + 'Cadastrar Comissão', + 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) @@ -187,7 +184,6 @@ class CadastrarComissaoView(FormMixin, GenericView): return reverse('comissao:list') - class ComposicaoForm(forms.Form): periodo = forms.CharField() diff --git a/materia/views.py b/materia/views.py index 61314e42d..49a918abd 100644 --- a/materia/views.py +++ b/materia/views.py @@ -2,8 +2,7 @@ from datetime import date, datetime from re import sub from crispy_forms.helper import FormHelper -from crispy_forms.layout import (HTML, ButtonHolder, Column, Fieldset, Layout, - Submit) +from crispy_forms.layout import ButtonHolder, Column, Fieldset, Layout, Submit from django import forms from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse diff --git a/sapl/context_processors.py b/sapl/context_processors.py index 29e570794..1adf9890a 100644 --- a/sapl/context_processors.py +++ b/sapl/context_processors.py @@ -3,7 +3,7 @@ from base.models import CasaLegislativa # TODO: this need to be cached and retrieved once!!! -def query_database(): +def query_database(): return CasaLegislativa.objects.first() @@ -29,4 +29,4 @@ def parliament_info(request): context['state'] = casa_legislativa.uf context['logotipo'] = casa_legislativa.logotipo - return context; + return context diff --git a/sapl/settings.py b/sapl/settings.py index f9f2c7639..3ee00751d 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -87,7 +87,7 @@ TEMPLATES = [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', "django.core.context_processors.media", - "django.core.context_processors.static", + "django.core.context_processors.static", 'django.contrib.messages.context_processors.messages', 'sapl.context_processors.parliament_info', ], diff --git a/sessao/urls.py b/sessao/urls.py index 13624b8b9..0a3e74dd6 100644 --- a/sessao/urls.py +++ b/sessao/urls.py @@ -1,5 +1,6 @@ from django.conf.urls import include, url +from sapl import settings from sessao.views import (EditExpedienteOrdemDiaView, EditMateriaOrdemDiaView, ExpedienteOrdemDiaView, ExpedienteView, ExplicacaoDelete, ExplicacaoEdit, ExplicacaoView, @@ -17,8 +18,6 @@ from sessao.views import (EditExpedienteOrdemDiaView, EditMateriaOrdemDiaView, VotacaoView, sessao_crud, tipo_expediente_crud, tipo_resultado_votacao_crud, tipo_sessao_crud) -from sapl import settings - urlpatterns_sessao = sessao_crud.urlpatterns + [ url(r'^(?P\d+)/expediente$', ExpedienteView.as_view(), name='expediente'), @@ -98,7 +97,7 @@ urlpatterns = [ sessao_crud.namespace, sessao_crud.namespace)), url(r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), - url(r'^sistema/sessao-plenaria/tipo/', include(tipo_sessao_crud.urls)), + url(r'^sistema/sessao-plenaria/tipo/', include(tipo_sessao_crud.urls)), url(r'^sistema/sessao-plenaria/tipo-resultado-votacao/', include(tipo_resultado_votacao_crud.urls)), url(r'^sistema/sessao-plenaria/tipo-expediente/',