Browse Source

Fix qa_check alerts

pull/98/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
e292cb51c2
  1. 19
      base/models.py
  2. 4
      base/urls.py
  3. 22
      base/views.py
  4. 5
      comissoes/urls.py
  5. 76
      comissoes/views.py
  6. 3
      materia/views.py
  7. 4
      sapl/context_processors.py
  8. 2
      sapl/settings.py
  9. 5
      sessao/urls.py

19
base/models.py

@ -1,6 +1,7 @@
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
def get_sessao_media_path(instance, subpath, filename): def get_sessao_media_path(instance, subpath, filename):
return './casa/%s/%s/%s' % (instance.codigo, 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): def get_casa_media_path(instance, filename):
return get_sessao_media_path(instance, 'Logotipo', filename) return get_sessao_media_path(instance, 'Logotipo', filename)
class CasaLegislativa(models.Model): class CasaLegislativa(models.Model):
# TODO ajustar todos os max_length !!!! # TODO ajustar todos os max_length !!!!
# cod_casa => id (pk) # cod_casa => id (pk)
@ -19,17 +21,24 @@ class CasaLegislativa(models.Model):
cep = models.CharField(max_length=100, verbose_name=_('CEP')) cep = models.CharField(max_length=100, verbose_name=_('CEP'))
municipio = models.CharField(max_length=100, verbose_name=_('Município')) municipio = models.CharField(max_length=100, verbose_name=_('Município'))
uf = models.CharField(max_length=100, verbose_name=_('UF')) uf = models.CharField(max_length=100, verbose_name=_('UF'))
telefone = models.CharField(max_length=100, blank=True, null=True, verbose_name=_('Telefone')) telefone = models.CharField(
fax = models.CharField(max_length=100, blank=True, null=True, verbose_name=_('Fax')) 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( logotipo = models.ImageField(
blank=True, blank=True,
null=True, null=True,
upload_to=get_casa_media_path, upload_to=get_casa_media_path,
verbose_name=_('Logotipo')) verbose_name=_('Logotipo'))
endereco_web = models.CharField(max_length=100, blank=True, null=True, verbose_name=_('HomePage')) endereco_web = models.CharField(
email = models.CharField(max_length=100, blank=True, null=True, verbose_name=_('E-mail')) 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( 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: class Meta:
verbose_name = _('Casa Legislativa') verbose_name = _('Casa Legislativa')

4
base/urls.py

@ -1,8 +1,7 @@
from django.conf.urls import url from django.conf.urls import url
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from .views import CasaLegislativaTableAuxView, HelpView
from .views import HelpView, CasaLegislativaTableAuxView
urlpatterns = [ urlpatterns = [
url(r'^sistema/', TemplateView.as_view(template_name='sistema.html')), url(r'^sistema/', TemplateView.as_view(template_name='sistema.html')),
@ -11,5 +10,4 @@ urlpatterns = [
name='help_base'), name='help_base'),
url(r'^casa-legislativa$', url(r'^casa-legislativa$',
CasaLegislativaTableAuxView.as_view(), name='casa_legislativa'), CasaLegislativaTableAuxView.as_view(), name='casa_legislativa'),
] ]

22
base/views.py

@ -1,6 +1,5 @@
import sapl
from crispy_forms.helper import FormHelper 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 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
@ -9,9 +8,9 @@ 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
from .models import CasaLegislativa import sapl
from sapl import settings from .models import CasaLegislativa
class HelpView(TemplateView): class HelpView(TemplateView):
@ -60,9 +59,8 @@ class CasaLegislativaTabelaAuxForm(ModelForm):
widget=forms.Select( widget=forms.Select(
attrs={'class': 'selector'})) attrs={'class': 'selector'}))
informacao_geral = forms.CharField(widget=forms.Textarea,
informacao_geral = forms.CharField(widget=forms.Textarea, label='Informação Geral',
label='Informação Geral',
required=False) required=False)
telefone = forms.CharField(label='Telefone', telefone = forms.CharField(label='Telefone',
@ -78,7 +76,7 @@ class CasaLegislativaTabelaAuxForm(ModelForm):
fax = forms.CharField(label='Fax', fax = forms.CharField(label='Fax',
required=False, required=False,
widget=forms.TextInput( widget=forms.TextInput(
attrs={'class': 'telefone'})) attrs={'class': 'telefone'}))
class Meta: class Meta:
@ -138,7 +136,7 @@ class CasaLegislativaTabelaAuxForm(ModelForm):
row4, row4,
row5, row5,
HTML("""{% if form.logotipo.value %} HTML("""{% if form.logotipo.value %}
<img class="img-responsive" <img class="img-responsive"
src="{{ MEDIA_URL }}{{ form.logotipo.value }}"> src="{{ MEDIA_URL }}{{ form.logotipo.value }}">
{% endif %}""", ), {% endif %}""", ),
row6, row6,
@ -177,11 +175,13 @@ class CasaLegislativaTableAuxView(FormMixin, GenericView):
casa_save = form.save(commit=False) casa_save = form.save(commit=False)
else: else:
casa_save = CasaLegislativaTabelaAuxForm( casa_save = CasaLegislativaTabelaAuxForm(
request.POST, request.FILES, instance=casa).save(commit=False) request.POST,
request.FILES,
instance=casa).save(commit=False)
casa_save.save() casa_save.save()
return self.form_valid(form) return self.form_valid(form)
else: else:
return self.render_to_response({'form': form}) return self.render_to_response({'form': form})
def get_success_url(self): def get_success_url(self):
return reverse('casa_legislativa') return reverse('casa_legislativa')

5
comissoes/urls.py

@ -1,10 +1,11 @@
from django.conf.urls import include, url from django.conf.urls import include, url
from comissoes.views import (ComissaoParlamentarEditView, from comissoes.views import (CadastrarComissaoView,
ComissaoParlamentarEditView,
ComissaoParlamentarIncluirView, ComposicaoView, ComissaoParlamentarIncluirView, ComposicaoView,
MateriasView, ReunioesView, cargo_crud, MateriasView, ReunioesView, cargo_crud,
comissao_crud, periodo_composicao_crud, comissao_crud, periodo_composicao_crud,
tipo_comissao_crud,CadastrarComissaoView) tipo_comissao_crud)
comissao_url_patterns = comissao_crud.urlpatterns + [ comissao_url_patterns = comissao_crud.urlpatterns + [
url(r'^(?P<pk>\d+)/composicao$', url(r'^(?P<pk>\d+)/composicao$',

76
comissoes/views.py

@ -1,5 +1,5 @@
from crispy_forms.helper import FormHelper 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 import forms
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.forms import ModelForm 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 django.views.generic.edit import FormMixin
from vanilla import GenericView from vanilla import GenericView
import sapl import sapl
from parlamentares.models import Filiacao, Parlamentar from parlamentares.models import Filiacao, Parlamentar
from sapl.crud import build_crud from sapl.crud import build_crud
@ -66,7 +65,6 @@ comissao_crud = build_crud(
class CadastrarComissaoForm(ModelForm): class CadastrarComissaoForm(ModelForm):
class Meta: class Meta:
@ -103,61 +101,60 @@ class CadastrarComissaoForm(ModelForm):
row2 = sapl.layout.to_row( row2 = sapl.layout.to_row(
[('tipo', 3), [('tipo', 3),
('data_criacao', 3), ('data_criacao', 3),
('unidade_deliberativa',3), ('unidade_deliberativa', 3),
('data_extincao',3)]) ('data_extincao', 3)])
row3 = sapl.layout.to_row( row3 = sapl.layout.to_row(
[('local_reuniao',4), [('local_reuniao', 4),
('agenda_reuniao',4), ('agenda_reuniao', 4),
('telefone_reuniao',4)]) ('telefone_reuniao', 4)])
row4 = sapl.layout.to_row( row4 = sapl.layout.to_row(
[('endereco_secretaria', 4), [('endereco_secretaria', 4),
('telefone_secretaria', 4), ('telefone_secretaria', 4),
('fax_secretaria', 4)]) ('fax_secretaria', 4)])
row5 = sapl.layout.to_row( row5 = sapl.layout.to_row(
[('secretario',6), [('secretario', 6),
('email',6)]) ('email', 6)])
row6 = sapl.layout.to_row( row6 = sapl.layout.to_row(
[('finalidade', 12)]) [('finalidade', 12)])
row7 = sapl.layout.to_row( row7 = sapl.layout.to_row(
[('apelido_temp', 9), [('apelido_temp', 9),
('data_instalacao_temp',3)]) ('data_instalacao_temp', 3)])
row8 = sapl.layout.to_row( row8 = sapl.layout.to_row(
[('data_final_prevista_temp',4), [('data_final_prevista_temp', 4),
('data_prorrogada_temp',4), ('data_prorrogada_temp', 4),
('data_fim_comissao',4)]) ('data_fim_comissao', 4)])
self.helper = FormHelper() self.helper = FormHelper()
self.helper.layout = Layout( self.helper.layout = Layout(
Fieldset( Fieldset(
'Cadastrar Comissão', 'Cadastrar Comissão',
Fieldset( Fieldset(
'Dados Básicos', 'Dados Básicos',
row1, row1,
row2 row2
), ),
Fieldset( Fieldset(
'Dados Complementares', 'Dados Complementares',
row3, row3,
row4, row4,
row5, row5,
row6 row6
), ),
Fieldset( Fieldset(
'Temporária', 'Temporária',
row7, row7,
row8 row8
), ),
ButtonHolder( ButtonHolder(
Submit('submit', 'Salvar', Submit('submit', 'Salvar',
css_class='button primary') css_class='button primary')
) )
) )
) )
super(CadastrarComissaoForm, self).__init__(*args, **kwargs) super(CadastrarComissaoForm, self).__init__(*args, **kwargs)
@ -187,7 +184,6 @@ class CadastrarComissaoView(FormMixin, GenericView):
return reverse('comissao:list') return reverse('comissao:list')
class ComposicaoForm(forms.Form): class ComposicaoForm(forms.Form):
periodo = forms.CharField() periodo = forms.CharField()

3
materia/views.py

@ -2,8 +2,7 @@ from datetime import date, datetime
from re import sub from re import sub
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import (HTML, ButtonHolder, Column, Fieldset, Layout, from crispy_forms.layout import ButtonHolder, Column, Fieldset, Layout, Submit
Submit)
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

4
sapl/context_processors.py

@ -3,7 +3,7 @@ from base.models import CasaLegislativa
# TODO: this need to be cached and retrieved once!!! # TODO: this need to be cached and retrieved once!!!
def query_database(): def query_database():
return CasaLegislativa.objects.first() return CasaLegislativa.objects.first()
@ -29,4 +29,4 @@ def parliament_info(request):
context['state'] = casa_legislativa.uf context['state'] = casa_legislativa.uf
context['logotipo'] = casa_legislativa.logotipo context['logotipo'] = casa_legislativa.logotipo
return context; return context

2
sapl/settings.py

@ -87,7 +87,7 @@ TEMPLATES = [
'django.template.context_processors.request', 'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
"django.core.context_processors.media", "django.core.context_processors.media",
"django.core.context_processors.static", "django.core.context_processors.static",
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
'sapl.context_processors.parliament_info', 'sapl.context_processors.parliament_info',
], ],

5
sessao/urls.py

@ -1,5 +1,6 @@
from django.conf.urls import include, url from django.conf.urls import include, url
from sapl import settings
from sessao.views import (EditExpedienteOrdemDiaView, EditMateriaOrdemDiaView, from sessao.views import (EditExpedienteOrdemDiaView, EditMateriaOrdemDiaView,
ExpedienteOrdemDiaView, ExpedienteView, ExpedienteOrdemDiaView, ExpedienteView,
ExplicacaoDelete, ExplicacaoEdit, ExplicacaoView, ExplicacaoDelete, ExplicacaoEdit, ExplicacaoView,
@ -17,8 +18,6 @@ from sessao.views import (EditExpedienteOrdemDiaView, EditMateriaOrdemDiaView,
VotacaoView, sessao_crud, tipo_expediente_crud, VotacaoView, sessao_crud, tipo_expediente_crud,
tipo_resultado_votacao_crud, tipo_sessao_crud) tipo_resultado_votacao_crud, tipo_sessao_crud)
from sapl import settings
urlpatterns_sessao = sessao_crud.urlpatterns + [ urlpatterns_sessao = sessao_crud.urlpatterns + [
url(r'^(?P<pk>\d+)/expediente$', url(r'^(?P<pk>\d+)/expediente$',
ExpedienteView.as_view(), name='expediente'), ExpedienteView.as_view(), name='expediente'),
@ -98,7 +97,7 @@ urlpatterns = [
sessao_crud.namespace, sessao_crud.namespace)), sessao_crud.namespace, sessao_crud.namespace)),
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}), {'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/', url(r'^sistema/sessao-plenaria/tipo-resultado-votacao/',
include(tipo_resultado_votacao_crud.urls)), include(tipo_resultado_votacao_crud.urls)),
url(r'^sistema/sessao-plenaria/tipo-expediente/', url(r'^sistema/sessao-plenaria/tipo-expediente/',

Loading…
Cancel
Save