Browse Source

Verifica se usuario existente

pull/941/head
Edward Ribeiro 8 years ago
parent
commit
3a2877ac63
  1. 6
      sapl/parlamentares/forms.py

6
sapl/parlamentares/forms.py

@ -3,6 +3,7 @@ from datetime import date, timedelta
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Fieldset, Layout
from django import forms
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group, User
from django.core.exceptions import ValidationError
from django.db import transaction
@ -289,6 +290,11 @@ class VotanteForm(ModelForm):
def clean(self):
cd = self.cleaned_data
username = cd['username']
if get_user_model().objects.filter(username=username).exists():
raise ValidationError(_('Não foi possível salvar registro,\
pois usuário existente'))
if ('senha' not in cd or 'senha_confirma' not in cd or
not cd['senha'] or not cd['senha_confirma']):
raise ValidationError(_(

Loading…
Cancel
Save