From a90bc08fb15312d622c086502c4ec915baa50cb2 Mon Sep 17 00:00:00 2001 From: Lincoln de Sousa Date: Thu, 27 Sep 2007 09:17:17 -0300 Subject: [PATCH] =?utf8?q?adicionando=20campo=20cpf=5Fcnpj=20na=20inscri?= =?utf8?q?=C3=A7=C3=A3o=20individual?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- eventos/models.py | 3 ++- forms.py | 9 +++++++++ views.py | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/eventos/models.py b/eventos/models.py index e698eab..d770b1f 100644 --- a/eventos/models.py +++ b/eventos/models.py @@ -96,9 +96,10 @@ class Participante(models.Model): cidade = models.CharField(maxlength=100) uf = models.CharField(maxlength=3) cep = models.CharField(maxlength=8) - usuario = models.ForeignKey(User) + cpf_cnpj = models.CharField(maxlength=20, blank=True) comercial = models.BooleanField(default=False) + usuario = models.ForeignKey(User) refbanco = models.IntegerField() class Admin: diff --git a/forms.py b/forms.py index f89c3c7..1f10f13 100644 --- a/forms.py +++ b/forms.py @@ -142,6 +142,15 @@ class InscricaoBase(LoginBase): class Inscricao(InscricaoBase): inscricao_comercial = forms.BooleanField(required=False, label='Inscrição Comercial') + cpf_cnpj = forms.CharField(max_length=20, required=False, label='CPF/CNPJ', + help_text='Somente necessário para a inscrição comercial') + + def clean_cpf_cnpj(self): + cpf_cnpj = self.cleaned_data['cpf_cnpj'] + if self.cleaned_data['inscricao_comercial'] and not cpf_cnpj: + raise ValidationError('Você escolheu a inscrição comercial, ' + 'portanto este campo se torna obrigatório') + return cpf_cnpj class InscricaoCaravana(InscricaoBase): lista_nomes = forms.CharField(label='Lista de nomes', diff --git a/views.py b/views.py index 290bfbf..e64e704 100644 --- a/views.py +++ b/views.py @@ -168,6 +168,7 @@ def inscricao_individual(request): p.telefone = cd['telefone'] p.home_page = cd['home_page'] p.comercial = cd['inscricao_comercial'] + p.cpf_cnpj = cd['cpf_cnpj'] p.save() u = authenticate(username=cd['nome_usuario'], password=cd['senha']) @@ -209,6 +210,7 @@ def inscricao_caravana(request): p.telefone = cd['telefone'] p.home_page = cd['home_page'] p.comercial = False # yeah, always false! + p.cpf_cnpj = '' p.save() c = Caravana() -- 2.20.1