Browse Source

Ajusta chamadas a métodos clean() dos formulários (#1773)

pull/1781/head
Edward 7 years ago
committed by GitHub
parent
commit
f65648fe64
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      sapl/base/forms.py
  2. 14
      sapl/comissoes/forms.py
  3. 5
      sapl/compilacao/forms.py
  4. 71
      sapl/materia/forms.py
  5. 8
      sapl/norma/forms.py
  6. 14
      sapl/parlamentares/forms.py
  7. 16
      sapl/protocoloadm/forms.py
  8. 9
      sapl/sessao/forms.py

9
sapl/base/forms.py

@ -314,6 +314,9 @@ class AutorForm(ModelForm):
def clean(self):
super(AutorForm, self).clean()
if not self.is_valid():
return self.cleaned_data
User = get_user_model()
cd = self.cleaned_data
@ -834,6 +837,9 @@ class RecuperarSenhaForm(PasswordResetForm):
def clean(self):
super(RecuperarSenhaForm, self).clean()
if not self.is_valid():
return self.cleaned_data
email_existente = User.objects.filter(
email=self.data['email']).exists()
@ -895,6 +901,9 @@ class AlterarSenhaForm(Form):
def clean(self):
super(AlterarSenhaForm, self).clean()
if not self.is_valid():
return self.cleaned_data
data = self.cleaned_data
new_password1 = data['new_password1']

14
sapl/comissoes/forms.py

@ -64,10 +64,6 @@ class ParticipacaoCreateForm(forms.ModelForm):
qs = q1 | q2 | q3
return qs
def clean(self):
super(ParticipacaoCreateForm, self).clean()
return self.cleaned_data
def verifica(self):
composicao = Composicao.objects.get(id=self.initial['parent_pk'])
participantes = composicao.participacao_set.all()
@ -125,6 +121,9 @@ class ComissaoForm(forms.ModelForm):
def clean(self):
super(ComissaoForm, self).clean()
if not self.is_valid():
return self.cleaned_data
if self.cleaned_data['data_extincao']:
if (self.cleaned_data['data_extincao'] <
self.cleaned_data['data_criacao']):
@ -160,6 +159,9 @@ class ReuniaoForm(ModelForm):
def clean(self):
super(ReuniaoForm, self).clean()
if not self.is_valid():
return self.cleaned_data
if self.cleaned_data['hora_fim']:
if (self.cleaned_data['hora_fim'] <
self.cleaned_data['hora_inicio']):
@ -189,10 +191,6 @@ class DocumentoAcessorioCreateForm(forms.ModelForm):
def create_documentoacessorio(self):
reuniao = Reuniao.objects.get(id=self.initial['parent_pk'])
def clean(self):
super(DocumentoAcessorioCreateForm, self).clean()
return self.cleaned_data
class DocumentoAcessorioEditForm(forms.ModelForm):

5
sapl/compilacao/forms.py

@ -1177,6 +1177,11 @@ class DispositivoEdicaoAlteracaoForm(ModelForm):
inst.dispositivo_atualizador)]
def clean(self):
super(DispositivoEdicaoAlteracaoForm, self).clean()
if not self.is_valid():
return self.cleaned_data
"""os cleans individuais do framework não puderam ser usados devido
a última validação compor dois valores
"""

71
sapl/materia/forms.py

@ -145,6 +145,9 @@ class MateriaSimplificadaForm(ModelForm):
def clean(self):
super(MateriaSimplificadaForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cleaned_data = self.cleaned_data
data_apresentacao = cleaned_data['data_apresentacao']
@ -167,6 +170,9 @@ class MateriaLegislativaForm(ModelForm):
def clean(self):
super(MateriaLegislativaForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cleaned_data = self.cleaned_data
data_apresentacao = cleaned_data['data_apresentacao']
@ -197,6 +203,9 @@ class UnidadeTramitacaoForm(ModelForm):
def clean(self):
super(UnidadeTramitacaoForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cleaned_data = self.cleaned_data
for key in list(cleaned_data.keys()):
@ -255,6 +264,9 @@ class RelatoriaForm(ModelForm):
def clean(self):
super(RelatoriaForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cleaned_data = self.cleaned_data
try:
@ -287,7 +299,12 @@ class TramitacaoForm(ModelForm):
self.fields['data_tramitacao'].initial = timezone.now().date()
def clean(self):
cleaned_data = super(TramitacaoForm, self).clean()
super(TramitacaoForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cleaned_data = self.cleaned_data
if 'data_encaminhamento' in cleaned_data:
data_enc_form = cleaned_data['data_encaminhamento']
@ -296,9 +313,6 @@ class TramitacaoForm(ModelForm):
if 'data_tramitacao' in cleaned_data:
data_tram_form = cleaned_data['data_tramitacao']
if self.errors:
return self.errors
ultima_tramitacao = Tramitacao.objects.filter(
materia_id=self.instance.materia_id).exclude(
id=self.instance.id).order_by(
@ -367,6 +381,11 @@ class TramitacaoUpdateForm(TramitacaoForm):
}
def clean(self):
super(TramitacaoUpdateForm, self).clean()
if not self.is_valid():
return self.cleaned_data
ultima_tramitacao = Tramitacao.objects.filter(
materia_id=self.instance.materia_id).order_by(
'-data_tramitacao',
@ -424,8 +443,8 @@ class LegislacaoCitadaForm(ModelForm):
def clean(self):
super(LegislacaoCitadaForm, self).clean()
if self.errors:
return self.errors
if not self.is_valid():
return self.cleaned_data
cleaned_data = self.cleaned_data
@ -487,8 +506,8 @@ class NumeracaoForm(ModelForm):
def clean(self):
super(NumeracaoForm, self).clean()
if self.errors:
return self.errors
if not self.is_valid():
return self.cleaned_data
try:
MateriaLegislativa.objects.get(
@ -532,8 +551,8 @@ class AnexadaForm(ModelForm):
def clean(self):
super(AnexadaForm, self).clean()
if self.errors:
return self.errors
if not self.is_valid():
return self.cleaned_data
cleaned_data = self.cleaned_data
@ -725,8 +744,8 @@ class DespachoInicialForm(ModelForm):
def clean(self):
super(DespachoInicialForm, self).clean()
if self.errors:
return self.errors
if not self.is_valid():
return self.cleaned_data
if DespachoInicial.objects.filter(
materia=self.instance.materia,
@ -770,8 +789,8 @@ class AutoriaForm(ModelForm):
def clean(self):
cd = super(AutoriaForm, self).clean()
if self.errors:
return self.errors
if not self.is_valid():
return self.cleaned_data
autorias = Autoria.objects.filter(
materia=self.instance.materia, autor=cd['autor'])
@ -993,6 +1012,9 @@ class TipoProposicaoForm(ModelForm):
def clean(self):
super(TipoProposicaoForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cd = self.cleaned_data
content_type = cd['content_type']
@ -1227,6 +1249,9 @@ class ProposicaoForm(forms.ModelForm):
def clean(self):
super(ProposicaoForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cd = self.cleaned_data
tm, am, nm = (cd.get('tipo_materia', ''),
@ -1319,6 +1344,9 @@ class DevolverProposicaoForm(forms.ModelForm):
def clean(self):
super(DevolverProposicaoForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cd = self.cleaned_data
if 'justificativa_devolucao' not in cd or\
@ -1501,6 +1529,9 @@ class ConfirmarProposicaoForm(ProposicaoForm):
def clean(self):
super(ConfirmarProposicaoForm, self).clean()
if not self.is_valid():
return self.cleaned_data
numeracao = sapl.base.models.AppConfig.attr('sequencia_numeracao')
if not numeracao:
@ -1825,6 +1856,11 @@ class EtiquetaPesquisaForm(forms.Form):
)
def clean(self):
super(EtiquetaPesquisaForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cleaned_data = self.cleaned_data
# Verifica se algum campo de data foi preenchido
@ -1893,7 +1929,12 @@ class FichaPesquisaForm(forms.Form):
)
def clean(self):
cleaned_data = super(FichaPesquisaForm, self).clean()
super(FichaPesquisaForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cleaned_data = self.cleaned_data
if not self.is_valid():
return cleaned_data

8
sapl/norma/forms.py

@ -193,8 +193,8 @@ class NormaRelacionadaForm(ModelForm):
def clean(self):
super(NormaRelacionadaForm, self).clean()
if self.errors:
return self.errors
if not self.is_valid():
return self.cleaned_data
cleaned_data = self.cleaned_data
try:
@ -263,6 +263,10 @@ class NormaPesquisaSimplesForm(forms.Form):
def clean(self):
super(NormaPesquisaSimplesForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cleaned_data = self.cleaned_data
data_inicial = cleaned_data['data_inicial']

14
sapl/parlamentares/forms.py

@ -258,8 +258,8 @@ class FiliacaoForm(ModelForm):
def clean(self):
super(FiliacaoForm, self).clean()
if self.errors:
return self.errors
if not self.is_valid():
return self.cleaned_data
filiacao = super(FiliacaoForm, self).save(commit=False)
validacao = validar_datas(self.cleaned_data['data'],
@ -282,6 +282,9 @@ class ComposicaoColigacaoForm(ModelForm):
def clean(self):
super(ComposicaoColigacaoForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cleaned_data = self.cleaned_data
pk = self.initial['coligacao_id']
if (ComposicaoColigacao.objects.filter(
@ -289,9 +292,7 @@ class ComposicaoColigacaoForm(ModelForm):
partido=cleaned_data.get('partido')).exists()):
msg = _('Esse partido já foi cadastrado nesta coligação.')
raise ValidationError(msg)
else:
if self.errors:
return self.errors
return self.cleaned_data
@ -352,6 +353,9 @@ class VotanteForm(ModelForm):
def clean(self):
super(VotanteForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cd = self.cleaned_data
username = cd['username']

16
sapl/protocoloadm/forms.py

@ -217,7 +217,7 @@ class AnularProcoloAdmForm(ModelForm):
def clean(self):
super(AnularProcoloAdmForm, self).clean()
cleaned_data = super(AnularProcoloAdmForm, self).clean()
cleaned_data = self.cleaned_data
if not self.is_valid():
return cleaned_data
@ -409,6 +409,9 @@ class ProtocoloMateriaForm(ModelForm):
def clean(self):
super(ProtocoloMateriaForm, self).clean()
if not self.is_valid():
return self.cleaned_data
data = self.cleaned_data
if self.is_valid():
if data['vincular_materia'] == 'True':
@ -485,6 +488,9 @@ class TramitacaoAdmForm(ModelForm):
def clean(self):
cleaned_data = super(TramitacaoAdmForm, self).clean()
if not self.is_valid():
return self.cleaned_data
if 'data_encaminhamento' in cleaned_data:
data_enc_form = cleaned_data['data_encaminhamento']
if 'data_fim_prazo' in cleaned_data:
@ -556,6 +562,11 @@ class TramitacaoAdmEditForm(TramitacaoAdmForm):
]
def clean(self):
super(TramitacaoAdmEditForm, self).clean()
if not self.is_valid():
return self.cleaned_data
ultima_tramitacao = TramitacaoAdministrativo.objects.filter(
documento_id=self.instance.documento_id).order_by(
'-data_tramitacao',
@ -617,6 +628,9 @@ class DocumentoAdministrativoForm(ModelForm):
def clean(self):
super(DocumentoAdministrativoForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cleaned_data = self.cleaned_data
if not self.is_valid():

9
sapl/sessao/forms.py

@ -109,6 +109,9 @@ class BancadaForm(ModelForm):
def clean(self):
super(BancadaForm, self).clean()
if not self.is_valid():
return self.cleaned_data
if self.cleaned_data['data_extincao']:
if (self.cleaned_data['data_extincao'] <
self.cleaned_data['data_criacao']):
@ -141,6 +144,9 @@ class BlocoForm(ModelForm):
def clean(self):
super(BlocoForm, self).clean()
if not self.is_valid():
return self.cleaned_data
if self.cleaned_data['data_extincao']:
if (self.cleaned_data['data_extincao'] <
self.cleaned_data['data_criacao']):
@ -523,6 +529,9 @@ class ResumoOrdenacaoForm(forms.Form):
def clean(self):
super(ResumoOrdenacaoForm, self).clean()
if not self.is_valid():
return self.cleaned_data
cleaned_data = self.cleaned_data
for c1 in cleaned_data:

Loading…
Cancel
Save