From fa12ead64c09f56f906c0e64a572eb6de85fe780 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Mon, 2 May 2016 10:56:35 -0300 Subject: [PATCH] =?UTF-8?q?Valida=20legisla=C3=A7=C3=A3o=20repetida?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- materia/forms.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/materia/forms.py b/materia/forms.py index a67b0f5ce..7da673da1 100644 --- a/materia/forms.py +++ b/materia/forms.py @@ -288,6 +288,13 @@ class LegislacaoCitadaForm(ModelForm): else: cleaned_data['norma'] = norma + if LegislacaoCitada.objects.filter( + materia=self.instance.materia, + norma=cleaned_data['norma'] + ).exists(): + msg = _('Essa legislação já foi cadastrada.') + raise ValidationError(msg) + return cleaned_data def save(self, commit=False):