From 8829879f74d14bd1a4abed6d4873a331b56a3652 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Wed, 25 Sep 2019 15:46:08 -0300 Subject: [PATCH] Evita que se criem autores com nomes repetidos --- sapl/base/forms.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sapl/base/forms.py b/sapl/base/forms.py index d51e0e321..e3ec2b6a9 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -618,6 +618,10 @@ class AutorForm(ModelForm): tipo = cd['tipo'] + if 'nome' in cd and \ + Autor.objects.filter(nome=cd['nome']).exists(): + raise ValidationError("Autor '%s' já existente!" % cd['nome']) + if not tipo.content_type: if 'nome' not in cd or not cd['nome']: self.logger.error('Nome do Autor não informado.')