Browse Source

HOT-FIX: somente checa unicidade de norma na inserção

rate-limiter-2026
Edward Ribeiro 8 years ago
parent
commit
f7e558988e
  1. 12
      sapl/norma/forms.py

12
sapl/norma/forms.py

@ -125,11 +125,13 @@ class NormaJuridicaForm(ModelForm):
if not self.is_valid(): if not self.is_valid():
return cleaned_data return cleaned_data
norma = NormaJuridica.objects.filter(ano=cleaned_data['ano'], if not self.instance:
numero=cleaned_data['numero'], norma = NormaJuridica.objects.filter(ano=cleaned_data['ano'],
tipo=cleaned_data['tipo']).exists() numero=cleaned_data['numero'],
if norma: tipo=cleaned_data['tipo']).exists()
raise ValidationError("Já existe uma norma de mesmo Tipo, Ano e Número no sistema") if norma:
raise ValidationError("Já existe uma norma de mesmo Tipo, Ano "
"e Número no sistema")
if (cleaned_data['tipo_materia'] and if (cleaned_data['tipo_materia'] and
cleaned_data['numero_materia'] and cleaned_data['numero_materia'] and
cleaned_data['ano_materia']): cleaned_data['ano_materia']):

Loading…
Cancel
Save