Browse Source

Fix #1820 - checa se data inicio > data_fim para periodo de comissao (#1822)

pull/1825/head
Edward 7 years ago
committed by Edward Ribeiro
parent
commit
c78dd48779
  1. 18
      sapl/comissoes/forms.py
  2. 13
      sapl/comissoes/views.py

18
sapl/comissoes/forms.py

@ -8,7 +8,7 @@ from django.utils.translation import ugettext_lazy as _
from sapl.base.models import Autor, TipoAutor from sapl.base.models import Autor, TipoAutor
from sapl.comissoes.models import (Comissao, Composicao, DocumentoAcessorio, from sapl.comissoes.models import (Comissao, Composicao, DocumentoAcessorio,
Participacao, Reuniao) Participacao, Reuniao, Periodo)
from sapl.parlamentares.models import Legislatura, Mandato, Parlamentar from sapl.parlamentares.models import Legislatura, Mandato, Parlamentar
class ComposicaoForm(forms.ModelForm): class ComposicaoForm(forms.ModelForm):
@ -39,6 +39,22 @@ class ComposicaoForm(forms.ModelForm):
return cleaned_data return cleaned_data
class PeriodoForm(forms.ModelForm):
class Meta:
model = Periodo
exclude = []
def clean(self):
cleaned_data = super(PeriodoForm, self).clean()
data_inicio = cleaned_data['data_inicio']
data_fim = cleaned_data['data_fim']
if data_fim and data_fim < data_inicio:
raise ValidationError('Data início não pode ser superior a data de fim')
return cleaned_data
class ParticipacaoCreateForm(forms.ModelForm): class ParticipacaoCreateForm(forms.ModelForm):
parent_pk = forms.CharField(required=False) # widget=forms.HiddenInput()) parent_pk = forms.CharField(required=False) # widget=forms.HiddenInput())

13
sapl/comissoes/views.py

@ -13,9 +13,9 @@ from sapl.base.models import AppConfig as AppsAppConfig
from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud,
CrudAux, MasterDetailCrud, CrudAux, MasterDetailCrud,
PermissionRequiredForAppCrudMixin) PermissionRequiredForAppCrudMixin)
from sapl.comissoes.forms import (ComissaoForm,ComposicaoForm, DocumentoAcessorioCreateForm, from sapl.comissoes.forms import (ComissaoForm, ComposicaoForm, DocumentoAcessorioCreateForm,
DocumentoAcessorioEditForm, ParticipacaoCreateForm, DocumentoAcessorioEditForm, ParticipacaoCreateForm,
ParticipacaoEditForm, ReuniaoForm) ParticipacaoEditForm, ReuniaoForm, PeriodoForm)
from sapl.materia.models import MateriaLegislativa, Tramitacao from sapl.materia.models import MateriaLegislativa, Tramitacao
@ -37,12 +37,19 @@ def pegar_url_reuniao(pk):
return url return url
CargoCrud = CrudAux.build(CargoComissao, 'cargo_comissao') CargoCrud = CrudAux.build(CargoComissao, 'cargo_comissao')
PeriodoComposicaoCrud = CrudAux.build(Periodo, 'periodo_composicao_comissao')
TipoComissaoCrud = CrudAux.build( TipoComissaoCrud = CrudAux.build(
TipoComissao, 'tipo_comissao', list_field_names=[ TipoComissao, 'tipo_comissao', list_field_names=[
'sigla', 'nome', 'natureza', 'dispositivo_regimental']) 'sigla', 'nome', 'natureza', 'dispositivo_regimental'])
class PeriodoComposicaoCrud(CrudAux):
model = Periodo
class CreateView(CrudAux.CreateView):
form_class = PeriodoForm
class UpdateView(CrudAux.UpdateView):
form_class = PeriodoForm
class ParticipacaoCrud(MasterDetailCrud): class ParticipacaoCrud(MasterDetailCrud):
model = Participacao model = Participacao

Loading…
Cancel
Save