Exemple #1
0
 def __init__(self, *args, **kwargs):
     super(BaseCadastroPessoaForm, self).__init__(*args, **kwargs)
     self.fields['estado'] = BRStateChoiceField(initial="PR")
     self.fields['cpf'] = BRCPFField(required=False, label=_(u"CPF"))
     self.fields['cep'] = BRZipCodeField(required=False)
     self.fields['telefone'] = BRPhoneNumberField(required=False)
     self.fields['celular'] = BRPhoneNumberField(required=False)
Exemple #2
0
 def clean(self):
     '''Define as regras de preenchimento e validação da Entidade Cliente.
     e as regras de validação de CPF ou CNPJ
     '''
     if self.telefone_fixo:
         BRPhoneNumberField().clean(self.telefone_fixo)
     if self.telefone_celular:
         BRPhoneNumberField().clean(self.telefone_celular)
     if self.cnpj and self.cnpj == '0' * 14:
         raise ValidationError({
             'cnpj': [
                 u'Embora Válido, não é aceito um CNPJ com %s ;' %
                 '000000000000000',
             ]
         })
Exemple #3
0
class MemberForm(forms.ModelForm):
    cpf = BRCPFField(label=_("CPF"), required=True)
    phone = BRPhoneNumberField(label=_("Phone"), required=False)
    github_user = forms.CharField(label=_("GitHub User"), required=False)
    organization = forms.CharField(label=_("Organization"),
                                   widget=OrganizationInput,
                                   required=False)
    location = forms.CharField(label=_("Location"), required=False)

    class Meta:
        model = Member
        exclude = ('user', )
        widgets = {'municipio': SelectMunicipioWidget}
        fields = ('category', 'github_user', 'organization', 'cpf', 'phone',
                  'address', 'location', 'municipio',
                  'relation_with_community', 'mailing', 'partner')

    def clean_organization(self):
        organization = self.cleaned_data['organization']
        if not organization:
            return None
        organization_instance, created = Organization.objects.get_or_create(
            name=organization)
        return organization_instance

    def save(self, user, commit=True):
        self.instance.user = user
        return super(MemberForm, self).save(commit)
Exemple #4
0
    def test_PhoneNumberFormField_deprecated(self):
        with warnings.catch_warnings(record=True) as recorded:
            warnings.simplefilter("always")
            AUPhoneNumberField()
            BEPhoneNumberField()
            BRPhoneNumberField()
            CAPhoneNumberField()
            CHPhoneNumberField()
            CNPhoneNumberField()
            CNCellNumberField()
            DKPhoneNumberField()
            ESPhoneNumberField()
            FRPhoneNumberField()
            GRPhoneNumberField()
            GRMobilePhoneNumberField()
            HKPhoneNumberField()
            HRPhoneNumberField()
            IDPhoneNumberField()
            ILMobilePhoneNumberField()
            INPhoneNumberField()
            ISPhoneNumberField()
            ITPhoneNumberField()
            NLPhoneNumberField()
            NOPhoneNumberField()
            NZPhoneNumberField()
            PKPhoneNumberField()
            PTPhoneNumberField()
            ROPhoneNumberField()
            SGPhoneNumberField()
            SIPhoneNumberField()
            TRPhoneNumberField()
            USPhoneNumberField()

        self.assertTrue(all(w.category is RemovedInLocalflavor20Warning for w in recorded))
Exemple #5
0
class ClientForm(forms.ModelForm):
    class Meta:
        model = Client
        form = Client
        widgets = {'state': BRStateSelect(), 'country': CountrySelectWidget()}
        fields = ['name', 'cpf', 'phone', 'cep', 'cnpj', 'state']

    cpf = BRCPFField()
    cep = BRZipCodeField(required=True)
    cnpj = BRCNPJField(label='CNPJ', required=False)
    phone = BRPhoneNumberField(label='Telefone')
Exemple #6
0
 def __init__(self, *args, **kwargs):
     super(AgenciaForm, self).__init__(*args, **kwargs)
     self.fields['cidade'].widget.attrs[
         'class'] = 'input-small campo-cidade'
     self.fields['estado'] = BRStateChoiceField(initial="PR")
     self.fields['estado'].widget.attrs[
         'class'] = 'input-small campo-estado'
     self.fields['cep'] = BRZipCodeField(required=False)
     self.fields['cep'].widget.attrs['class'] = 'input-mini campo-cep'
     self.fields['contato'] = BRPhoneNumberField(required=False)
     self.fields['contato'].widget.attrs[
         'class'] = 'input-small campo-contato'
Exemple #7
0
class FormCliente(forms.ModelForm):
	cpf = BRCPFField(widget=CPFInput, label='CPF')
	telefone = BRPhoneNumberField(widget=BRPhoneNumberInput, required=False)
	
	def clean_telefone(self):
		value = self.cleaned_data['telefone']
		value = re.sub('-', '', smart_text(value))
		if value == '':
			return None
		else:
			return int(value)
	class Meta:
		model = Cliente
		fields = ['nome', 'sobrenome', 'cpf', 'codigo', 'sexo', 'estado_civil','telefone',]
Exemple #8
0
class FormUsuario(forms.ModelForm):
	error_messages = {
		'password_mismatch': _("The two password fields didn't match."),
	}

	cpf = BRCPFField(widget=CPFInput, label='CPF')
	telefone = BRPhoneNumberField(widget=BRPhoneNumberInput, required=False)
	password1 = forms.CharField(label=_("Password"), 
		widget=forms.PasswordInput)
	password2 = forms.CharField(label=_("Password confirmation"),
		widget=forms.PasswordInput,
	help_text=_("Enter the same password as before, for verification."))

	def __init__(self, *args, **kwargs):
		super(FormUsuario, self).__init__(*args, **kwargs)
		self.fields['cpf'].widget.attrs.update({'autofocus': ''})

	def clean_password2(self):
		password1 = self.cleaned_data.get("password1")
		password2 = self.cleaned_data.get("password2")
		if password1 and password2 and password1 != password2:
			raise forms.ValidationError(
				self.error_messages['password_mismatch'],
				code='password_mismatch',
			)
		self.instance.cpf = self.cleaned_data.get('cpf')
		password_validation.validate_password(self.cleaned_data.get('password2'), self.instance)
		return password2

	def save(self, commit=True):
		user = super(FormUsuario, self).save(commit=False)
		user.set_password(self.cleaned_data["password1"])
		if commit:
			user.save()
		return user

	def clean_telefone(self):
		value = self.cleaned_data['telefone']
		value = re.sub('-', '', smart_text(value))
		if value == '':
			return None
		else:
			return int(value)
	
	class Meta:
		model = Usuario

		fields = ['cpf', 'nome', 'sobrenome', 'tipo', 'codigo', 'email', 'telefone',
		'nascimento',]
Exemple #9
0
class FormPurchase(CommonForm):
    insured_cpf = BRCPFField(label="CPF")
    insured_name = forms.CharField(max_length=100, label="Nome")
    birth_date = forms.DateField(
        label="Data de Nascimento",
        widget=forms.widgets.DateInput(attrs={'class': 'date'}))
    card_name = forms.CharField(max_length=100, label="Nome no cartão")
    card_cpf = BRCPFField(label="CPF")
    card_number = forms.CharField(max_length=16, label="Número do cartão")
    card_mouth = forms.ChoiceField(choices=(
        ('', '--'),
        ('1', '1'),
        ('2', '2'),
        ('3', '3'),
        ('4', '4'),
        ('5', '5'),
        ('6', '6'),
        ('7', '7'),
        ('8', '8'),
        ('9', '9'),
        ('10', '10'),
        ('11', '11'),
        ('12', '12'),
    ),
                                   label="Validade mês")
    card_year = forms.ChoiceField(choices=(
        ('', '----'),
        ('2017', '2017'),
        ('2018', '2018'),
        ('2019', '2019'),
        ('2020', '2020'),
        ('2021', '2021'),
        ('2022', '2022'),
        ('2023', '2023'),
        ('2024', '2024'),
        ('2025', '2025'),
        ('2026', '2026'),
        ('2027', '2027'),
        ('2028', '2028'),
        ('2029', '2029'),
        ('2030', '2030'),
        ('2031', '2031'),
    ),
                                  label="Validade ano")
    card_cvv = forms.CharField(max_length=4, label="CVV")
    buy_name = forms.CharField(max_length=100, label="Nome para contato")
    buy_email = forms.EmailField(label="Email para contato")
    buy_phone = BRPhoneNumberField(label="Telefone para contato")
Exemple #10
0
class UserForm(forms.ModelForm):
    password = forms.CharField(widget=forms.PasswordInput)
    telefone = BRPhoneNumberField(required=True,
                                  widget=forms.TextInput(
                                      attrs={
                                          'data-mask': '(00)00000-0000',
                                          'class': '.phone',
                                          'placeholder': '(__)_____-____'
                                      }))

    class Meta:
        model = User
        fields = [
            'first_name', 'last_name', 'username', 'email', 'password',
            'telefone', 'descricao'
        ]
Exemple #11
0
class MemberForm(forms.ModelForm):
    cpf = BRCPFField(label=_("CPF"), required=True)
    phone = BRPhoneNumberField(label=_("Phone"), required=False)
    github_user = forms.CharField(label=_("GitHub User"), required=False)
    organization = forms.CharField(label=_("Organization"),
                                   widget=OrganizationInput,
                                   required=False)
    location = forms.CharField(label=_("Location"), required=False)

    class Meta:
        model = Member
        exclude = ('user', )
        widgets = {'municipio': SelectMunicipioWidget}
        fields = ('category', 'github_user', 'organization', 'cpf', 'phone',
                  'address', 'location', 'municipio',
                  'relation_with_community', 'mailing', 'partner')

    def __init__(self, *args, **kwargs):
        super(MemberForm, self).__init__(*args, **kwargs)
        # if self.instance:
        #     if not self.instance.get_payment_status():
        #         self.fields['category'].widget.attrs['disabled'] = 'disabled'

    def clean_category(self):
        category = self.cleaned_data['category']
        if self.instance.id:
            if not self.instance.get_payment_status():
                if self.instance.category != category:
                    raise forms.ValidationError(
                        _("You can't change your category with pending payments"
                          ))
        return category

    def clean_organization(self):
        organization = self.cleaned_data['organization']
        if not organization:
            return None
        organization_instance, created = Organization.objects.get_or_create(
            name=organization)
        return organization_instance

    def save(self, user, commit=True):
        self.instance.user = user
        return super(MemberForm, self).save(commit)
Exemple #12
0
class EmpresaForm(ModelForm):
    telefone = BRPhoneNumberField(required=True)

    class Meta:
        model = Empresa
        fields = '__all__'