From 034c08491fbadedd30f34972c2c219bbeae574b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pedro=20Sconetto?= Date: Thu, 7 Jun 2018 15:46:14 -0300 Subject: [PATCH] Fix #1964 (#1979) --- sapl/norma/forms.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sapl/norma/forms.py b/sapl/norma/forms.py index 81f487c79..2574edb20 100644 --- a/sapl/norma/forms.py +++ b/sapl/norma/forms.py @@ -125,7 +125,11 @@ class NormaJuridicaForm(ModelForm): if not self.is_valid(): return cleaned_data - + norma = NormaJuridica.objects.filter(ano=cleaned_data['ano'], + numero=cleaned_data['numero'], + tipo=cleaned_data['tipo']).exists() + if norma: + raise ValidationError("Já existe uma norma de mesmo Tipo, Ano e Número no sistema") if (cleaned_data['tipo_materia'] and cleaned_data['numero_materia'] and cleaned_data['ano_materia']):