def make_valida_form(self, **kwargs): valid = dict(name='Vicente Luz', cpf='12345678901', email='*****@*****.**', phone='86-98822-1812') data = dict(valid, **kwargs) form = InscricaoForm(data) form.is_valid() return form
def criar(request): form = InscricaoForm(request.POST) if not form.is_valid(): return render(request, 'inscricoes/inscricao_form.html', {'form': form}) enviar_email('Confirmação de inscrição', settings.DEFAULT_FROM_EMAIL, form.cleaned_data['email'], 'inscricoes/inscricao_email.txt', form.cleaned_data) messages.success(request, 'Inscrição realizada com sucesso!') return HttpResponseRedirect('/inscricao/')
def create(request): form = InscricaoForm(request.POST) if not form.is_valid(): return render(request, 'inscricao_form.html', {'form': form}) incricao = form.save() #incricao = Inscricao.objects.create(**form.cleaned_data) envia_email('Confirmacao de Inscricao', settings.DEFAULT_FROM_EMAIL, incricao.email, 'inscricao_email.txt', {'inscricao': incricao}) return HttpResponseRedirect(r('inscricoes:detail', incricao.pk))
def novo(request): return render(request, 'inscricoes/inscricao_form.html', {'form': InscricaoForm()})
def setUp(self): self.form = InscricaoForm()
def input_form(request): return render(request, 'inscricao_form.html', {'form': InscricaoForm()})
def test_has_fields(self): '''Form must have foour fields''' form = InscricaoForm() expected = ['name', 'cpf', 'email', 'phone'] self.assertSequenceEqual(expected, list(form.fields))