Exemple #1
0
 def test_extra_attrs(self):
     widget = IntlTelInputWidget()
     attrs = widget.build_attrs(extra_attrs={'required': True})
     self.assertTrue(attrs['required'])
     attrs = widget.build_attrs()
     self.assertIsNone(attrs.get('required'))
     self.assertEqual(attrs['size'], '2')
Exemple #2
0
 class Meta:
     model = Client
     exclude = ('uuid', 'created_datetime', 'created_by', 'last_modified',
                'last_modified_by')
     widgets = {
         'phone1': IntlTelInputWidget(default_code='us'),
         'phone2': IntlTelInputWidget(default_code='us'),
         'phone3': IntlTelInputWidget(default_code='us'),
         'emergency_phone': IntlTelInputWidget(default_code='us'),
         'insured_phone': IntlTelInputWidget(default_code='us'),
     }
Exemple #3
0
    class Meta:
        model = Client
        fields = ('first_name', 'last_name', 'phone1', 'phone2', 'phone3',
                  'primary_email', 'secondary_email', 'billing_type',
                  'referred_by', 'client_minor',
                  'send_email_appointment_reminders', 'access_client_portal')
        required = ('first_name', 'email')

        widgets = {
            'phone1': IntlTelInputWidget(default_code='us'),
            'phone2': IntlTelInputWidget(default_code='us'),
            'phone3': IntlTelInputWidget(default_code='us'),
        }
Exemple #4
0
class UserProfileEdithForm(forms.ModelForm):

    phone = forms.CharField(widget=IntlTelInputWidget())

    class Meta:
        model = User
        fields = ('first_name', 'last_name', 'phone')

    def clean_first_name(self):
        if self.is_valid():
            first_name = self.cleaned_data['first_name']
            try:
                user = User.objects.exclude(pk=self.instance.pk).get(
                    first_name=first_name)
            except User.DoesNotExist:
                return first_name

            raise forms.ValidationError('First Name "%s" is already in use.' %
                                        first_name)

    def clean_last_name(self):
        if self.is_valid():
            last_name = self.cleaned_data['last_name']
            try:
                user = User.objects.exclude(pk=self.instance.pk).get(
                    last_name=last_name)
            except User.DoesNotExist:
                return last_name

            raise forms.ValidationError('Last Name "%s" is already in use.' %
                                        last_name)
Exemple #5
0
class CustomUserUpdateForm(forms.ModelForm):
    name = forms.CharField(
        max_length=150,
        widget=forms.TextInput(attrs={
            'placeholder': _('Full Name'),
            'autofocus': 'autofocus'
        }))
    phone = PhoneNumberField(
        widget=IntlTelInputWidget(allow_dropdown=True,
                                  preferred_countries=['br', 'us', 'es', 'ar'],
                                  default_code='br'))

    class Meta:
        model = User
        fields = ("name", "phone")

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.include_media = False
        self.helper.form_show_labels = False
        self.helper.layout = Layout(
            PrependedText('name', '<i class="ni ni-circle-08"></i>'),
            Field('phone', css_class='input-group-alternative'),
            Div(Submit('submit',
                       _('Save Account'),
                       css_class='btn btn-primary my-4 btn-block'),
                css_class='text-center'))
class TelFormAttrs(forms.Form):
    tel_number = forms.CharField(
        widget=IntlTelInputWidget(attrs={
            'title': 'Telephone number',
            'placeholder': 'foobar'
        },
                                  preferred_countries=['jp'],
                                  default_code='jp'))
Exemple #7
0
class UserCreationForm(RegForm):
    email = forms.EmailField(max_length=60,
                             help_text='Required. Enter a valid email address')
    phone = forms.CharField(widget=IntlTelInputWidget())
    referered_by = forms.CharField()

    def __init__(self, *args, **kwargs):
        super(UserCreationForm, self).__init__(*args, **kwargs)
        self.fields['referered_by'].required = False

    class Meta:
        model = User
        fields = ('referered_by', 'email', 'first_name', 'last_name',
                  'password1', 'password2', 'phone')

    def clean_first_name(self):
        # Get the email
        first_name = self.cleaned_data.get('first_name')

        # Check to see if any users already exist with this email as a username.
        try:
            match = User.objects.get(first_name=first_name)
        except User.DoesNotExist:
            # Unable to find a user, this is fine
            return first_name

        # A user was found with this as a username, raise an error.
        raise forms.ValidationError('This first name  is already in use.')

    def clean_last_name(self):
        # Get the email
        last_name = self.cleaned_data.get('last_name')

        # Check to see if any users already exist with this email as a username.
        try:
            match = User.objects.get(last_name=last_name)
        except User.DoesNotExist:
            # Unable to find a user, this is fine
            return last_name

        # A user was found with this as a username, raise an error.
        raise forms.ValidationError('This last name is already in use.')

    def clean_email(self):
        # Get the email
        email = self.cleaned_data.get('email')

        # Check to see if any users already exist with this email as a username.
        try:
            match = User.objects.get(email=email)
        except User.DoesNotExist:
            # Unable to find a user, this is fine
            return email

        # A user was found with this as a username, raise an error.
        raise forms.ValidationError('This email address is not available.')
Exemple #8
0
 class Meta:
     model = Donor
     fields = [
         'age', 'sex', 'blood_group', 'covid_recovory_date', 'location',
         'phone'
     ]
     widgets = {
         'covid_recovory_date': DatePickerInput(),
         'phone': IntlTelInputWidget(default_code='in'),
     }
Exemple #9
0
 class Meta:
     model = Customer
     fields = ('username', 'first_name', 'last_name', 'email', 'phone',
               'timezone')
     labels = {
         "username": "******",
         "first_name": "First Name",
         "last_name": "Last Name",
         "email": "Email ID",
         "phone": "Valid Phone number",
     }
     widgets = {'phone': IntlTelInputWidget(default_code='us')}
Exemple #10
0
class UserContactForm(forms.ModelForm):
    phone = forms.CharField(widget=IntlTelInputWidget())

    class Meta:
        model = ContactForm
        fields = (
            'name',
            'email',
            'subject',
            'phone',
            'message',
        )
Exemple #11
0
    class Meta:
        model = RaiseRequest
        fields = ['name','email','phone_number','description','issue','image']
        error_messages = {
            NON_FIELD_ERRORS: {
                'unique_together': "unique",
            }
        }

        widgets = {'description':forms.Textarea(attrs={'rows': 3, 'placeholder':'Let us know. What problem are you facing at Piblitz?'}),
                    'phone_number':IntlTelInputWidget(attrs={'style':'width=100%;'},default_code='IN')
        }
Exemple #12
0
class TeamMemberUpdateForm(forms.Form):
    is_clinician = forms.BooleanField(initial=True, required=False)
    is_scheduler = forms.BooleanField(initial=True, required=False)
    is_biller = forms.BooleanField(initial=False, required=False)
    first_name = forms.CharField()
    last_name = forms.CharField()
    phone = forms.CharField(widget=IntlTelInputWidget(default_code='us'))
    email = forms.CharField()

    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user_obj')  # cache the user object you pass in
        super(TeamMemberUpdateForm, self).__init__(*args, **kwargs)

    def clean_email(self):
        email = self.cleaned_data.get('email')
        qs = User.objects.filter(email=email)
        if qs:
            if self.user != qs.first():
                raise forms.ValidationError("email is taken")
        return email

    def clean_username(self):
        username = self.cleaned_data.get('username')
        qs = User.objects.filter(username=username)
        if qs:
            if self.user != qs.first():
                raise forms.ValidationError("Username is taken")
        return username

    def clean_phone(self):
        phone = self.cleaned_data.get('phone')
        qs = User.objects.filter(phone=phone)
        if qs.exists():
            if self.user != qs.first():
                raise forms.ValidationError(
                    "Phone Number is already registered")
        ph = parse(phone)
        if not is_valid_number(ph):
            raise forms.ValidationError("Phone Number is Invalid")
        return phone
class ContactUs(forms.Form):
    name = forms.CharField(
        widget=forms.TextInput(attrs={"placeholder": "Your Name"}),
        required=True,
        max_length=255,
    )
    email = forms.EmailField(
        widget=forms.EmailInput(attrs={"placeholder": "*****@*****.**"}),
        required=True,
    )
    phone = forms.CharField(widget=IntlTelInputWidget(
        default_code="zm", preferred_countries=["za", "na"]))
    subject = forms.CharField(
        widget=forms.TextInput(attrs={"placeholder": "Subject"}),
        required=True,
        max_length=255,
    )
    message = forms.CharField(
        required=True,
        max_length=1000,
        widget=forms.Textarea(attrs={"placeholder": "Message"}),
    )
    captcha = ReCaptchaField()
Exemple #14
0
 class Meta:
     model = User
     fields = (
         'username',
         'first_name',
         'last_name',
         'email',
         'phone',
         'is_clinician',
         'is_scheduler',
         'is_biller',
     )
     required = ('username', 'first_name', 'last_name', 'email', 'phone')
     labels = {
         "username": "******",
         "first_name": "First Name",
         "last_name": "Last Name",
         "email": "Email ID",
         "phone": "Valid Phone number",
         "is_clinician": "Clinician Role",
         "is_scheduler": "Can Schedule Appointments",
         "is_biller": "Can Manage Billing",
     }
     widgets = {'phone': IntlTelInputWidget(default_code='us')}
Exemple #15
0
class CustomSignupForm(SignupForm):
    name = forms.CharField(
        label=_('Full Name'),
        max_length=150,
        widget=forms.TextInput(attrs={
            'placeholder': _('Full Name'),
            'autofocus': 'autofocus'
        }))
    phone = PhoneNumberField(label=_('Phone'),
                             widget=IntlTelInputWidget(
                                 allow_dropdown=True,
                                 preferred_countries=['br', 'us', 'es', 'ar'],
                                 default_code='br'))

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.include_media = False
        self.helper.form_show_labels = False
        self.helper.layout = Layout(
            PrependedText('name', '<i class="ni ni-circle-08"></i>'),
            Field('phone', css_class='input-group-alternative'),
            PrependedText('email', '<i class="ni ni-email-83"></i>'),
            PrependedText('password1',
                          '<i class="ni ni-lock-circle-open"></i>'),
            Div(Submit('submit',
                       _('Sign up'),
                       css_class='btn btn-primary my-4'),
                css_class='text-center'))

    def save(self, request):
        user = super(CustomSignupForm, self).save(request)
        user.name = self.cleaned_data['name']
        user.phone = self.cleaned_data['phone']
        user.save()
        return user
Exemple #16
0
class TelForm(forms.Form):
    tel_number = forms.CharField(widget=IntlTelInputWidget(), required=True)
Exemple #17
0
class TwoTelForm(TelForm):
    tel_number_2 = forms.CharField(widget=IntlTelInputWidget())
Exemple #18
0
class TelFormNoInit(forms.Form):
    tel_number = forms.CharField(widget=IntlTelInputWidget(
        use_default_init=False))
class UserContactFormRequest(forms.ModelForm):
    phone = forms.CharField(widget=IntlTelInputWidget())
    class Meta:
        model = ContactFormRequest
        fields = ('request_type','name','email','company_name','phone','message',)