Beispiel #1
0
    def __init__(self, *args, submit_button_name="Submit", **kwargs):
        super(OrderForm, self).__init__(*args, **kwargs)
        self.fields['requester_name'].label = "Your full name"
        self.fields['requester_email'].label = "Your email address"
        self.fields['requester_phone_number'].label = "Your phone number"
        self.fields['quantity'].label = "Number of pounds of blueberries"
        self.fields[
            'requester_phone_number'].widget = PhoneNumberInternationalFallbackWidget(
                region='us')
        self.fields['pickup_date'].widget = \
            DateTimePicker(options={"format": "MM/DD/YYYY"})

        if settings.DEBUG:
            self.fields['quantity'].initial = 1000
            self.fields['requester_name'].initial = "Charles Reid"
            self.fields['requester_email'].initial = "*****@*****.**"
            self.fields['requester_phone_number'].initial = "5035555678"
            self.fields['pickup_date'].initial = "06/20/2017"

        self.helper = FormHelper()
        self.helper.form_method = 'POST'
        self.helper.form_action = 'submit_survey'
        self.helper.form_class = 'form-inline'
        self.helper.field_template = 'bootstrap3/layout/inline_field.html'
        self.helper.layout = Layout(*self.fields.keys())
        self.helper.add_input(Submit('submit', submit_button_name))
class ApplicationForm(forms.ModelForm):
    """
    Uses bootstrap_datepicker_plus for dates and phonenumber_field
    for phone field. Sends email with info to page mail account.
    """

    parent = forms.CharField(
        label='Родител',
        required=True,
        validators=[MaxLengthValidator(40)],
        max_length=50,
        widget=forms.TextInput(attrs={'class': 'form-control'}))

    child = forms.CharField(
        label='Дете',
        required=True,
        validators=[MaxLengthValidator(40)],
        max_length=50,
        widget=forms.TextInput(attrs={'class': 'form-control'}))

    school = forms.CharField(
        label='Училище',
        required=True,
        validators=[MaxLengthValidator(70)],
        max_length=50,
        widget=forms.TextInput(attrs={'class': 'form-control'}))
    group = forms.ChoiceField(
        label='Клас/група',
        required=True,
        choices=ChildApplication.GROUP_CHOICES,
        widget=forms.Select(attrs={'class': 'form-control'}))

    period_from = forms.DateField(label='В периода от',
                                  required=True,
                                  widget=DatePickerInput(options={
                                      "locale": "bg",
                                  }))

    period_to = forms.DateField(label='до',
                                required=True,
                                widget=DatePickerInput(options={
                                    "locale": "bg",
                                }))

    phone = PhoneNumberField(label='Телефон за връзка',
                             required=True,
                             max_length=20,
                             widget=PhoneNumberInternationalFallbackWidget(
                                 attrs={'class': 'form-control'}))

    extra = forms.CharField(
        label='Допълнителна информация',
        required=False,
        validators=[MaxLengthValidator(1000)],
        max_length=1000,
        widget=forms.Textarea(attrs={'class': 'form-control'}))

    class Meta:
        model = ChildApplication
        fields = '__all__'
Beispiel #3
0
    class Meta:
        model = Client

        fields = [
            'name', 'address', 'birthday', 'phone_number',
            'email_address', 'additional_info',
        ]
        widgets = {
            'address': forms.TextInput(
                attrs={
                    "class": "form-control",
                    "placeholder": "Адрес проживания"
                }
            ),
            'name': forms.TextInput(
                attrs={"class": "form-control", "placeholder": "ФИО"}
            ),
            'phone_number': PhoneNumberInternationalFallbackWidget(
                attrs={'data-phone': True, "placeholder": "+7 919 123 45 67"}
            ),
            'email_address': forms.EmailInput(
                attrs={
                    "class": "form-control",
                    "placeholder": "*****@*****.**"}
            ),
            'additional_info': forms.Textarea(
                attrs={
                    "class": "form-control",
                    "rows": "4",
                    "placeholder": "Здесь вы можете указать информацию о клиенте и дополнительные номера телефонов",
                }
            )
        }
Beispiel #4
0
 class Meta:
     model = UserAccept
     exclude = ['rating', 'imp', 'user']
     widgets = {
         'phone_number':
         PhoneNumberInternationalFallbackWidget(attrs={
             'class': 'form-control',
         }),
         'social_net':
         forms.URLInput(attrs={
             'class': 'form-control',
         }),
         'date_birth':
         forms.DateInput(attrs={
             'class': 'form-control',
         }),
         'gov':
         forms.Select(attrs={
             'class': 'custom-select',
         }),
         'position':
         forms.TextInput(attrs={
             'class': 'form-control',
         }),
         'avatar':
         forms.FileInput(attrs={
             'class': 'user-edit-fileinput',
         }),
     }
Beispiel #5
0
class GuestForm(forms.Form):
    phonenumber = PhoneNumberField(
        widget=PhoneNumberInternationalFallbackWidget(
            attrs={
                "class": "form-control",
                "placeholder": "Phone Number"
            }))
Beispiel #6
0
    class Meta:
        model = get_user_model()

        widgets = {
            'first_name':
            forms.TextInput(attrs={'class': 'form-control input-lg'}),
            'last_name':
            forms.TextInput(attrs={'class': 'form-control input-lg'}),
            'offsprings_surname':
            forms.TextInput(attrs={'class': 'form-control input-lg'}),
            'phone':
            PhoneNumberInternationalFallbackWidget(
                attrs={'class': 'form-control input-lg'}),
            'email':
            forms.EmailInput(attrs={'class': 'form-control input-lg'}),
            'father_name':
            forms.TextInput(attrs={'class': 'form-control input-lg'}),
            'mother_name':
            forms.TextInput(attrs={'class': 'form-control input-lg'}),
            'password1':
            forms.PasswordInput(attrs={'class': 'form-control input-lg'}),
            'password2':
            forms.PasswordInput(attrs={'class': 'form-control input-lg'}),
        }
        fields = ('first_name', 'last_name', 'phone', 'offsprings_surname',
                  'email', 'father_name', 'mother_name')
Beispiel #7
0
 class Meta:
     model = Manager
     fields = ('phone_number',)
     widgets = {
         'phone_number': PhoneNumberInternationalFallbackWidget(
             attrs={'data-phone': True}
         ),
     }
Beispiel #8
0
class CustomSignupForm(SignupForm):

    mobile = PhoneNumberField(widget = PhoneNumberInternationalFallbackWidget())

    def signup(self, request, user):
        user.mobile = self.cleaned_data['mobile']
        user.save()
        return user
Beispiel #9
0
 class Meta:
     model = Shop
     fields = ['name', 'email', 'phone']
     #widgets = {'phone': PhoneNumberPrefixWidget(initial='DK',attrs={'class': 'form-control'})} # 'initial' not working in package
     widgets = {
         'phone':
         PhoneNumberInternationalFallbackWidget(
             attrs={'class': 'form-control'})
     }
Beispiel #10
0
class ClinicConfigurationAdminForm(forms.ModelForm):
    phone_number = FormPhoneNumberField(
        label='Numéro de téléphone de la clinique',
        widget=PhoneNumberInternationalFallbackWidget(),
    )

    class Meta:
        model = ClinicConfiguration
        fields = "__all__"
Beispiel #11
0
    def __init__(self, *args, **kwargs):
        super(StaffForm, self).__init__(*args, **kwargs)

        self.fields['phone'] = PhoneNumberField(
            widget=PhoneNumberInternationalFallbackWidget(
                attrs={'class': 'form-control international-inputmask'}),
            label="Телефон")
        self.fields['occupation'].widget.attrs.update(
            {'class': 'form-control select2'})
Beispiel #12
0
class EnterpriseUpdateContactForm(forms.Form):
    city = forms.ModelChoiceField(City.objects.all(),
                                  widget=forms.Select(attrs={'class': 'form-control'}),
                                  label="Город")
    address = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}),
                              label="Адрес")
    phone = forms.CharField(widget=PhoneNumberInternationalFallbackWidget(attrs={
        'class': 'form-control',
        'data-mask': '+38 (999) 999-99-99'
    }), label="Контактный телефон")
    def test_fallback_widget_switches_between_national_and_international(self):
        region, number_string = self.local_numbers[0]
        number = PhoneNumber.from_string(number_string, region=region)
        gb_widget = PhoneNumberInternationalFallbackWidget(region="GB")
        de_widget = PhoneNumberInternationalFallbackWidget(region="DE")
        self.assertHTMLEqual(
            gb_widget.render("number", number),
            '<input name="number" type="text" value="01606 75178" />',
        )
        self.assertHTMLEqual(
            de_widget.render("number", number),
            '<input name="number" type="text" value="+44 1606 75178" />',
        )

        # If there's been a validation error, the value should be included verbatim
        self.assertHTMLEqual(
            gb_widget.render("number", "error"),
            '<input name="number" type="text" value="error" />',
        )
Beispiel #14
0
 class Meta:
     model = Shop
     fields = [
         'cvr_number', 'name', 'address', 'postcode_special',
         'city_special', 'email', 'phone'
     ]
     widgets = {
         'phone':
         PhoneNumberInternationalFallbackWidget(
             attrs={'class': 'form-control'})
     }
Beispiel #15
0
 class Meta:
     model = Coach
     fields = ('phone_number',)
     widgets = {
         'phone_number': PhoneNumberInternationalFallbackWidget(
             attrs={'data-phone': True}
         ),
         'vk_page': TextInput(
             attrs={'placeholder': 'Ссылка на страницу пользователя'}
         )
     }
Beispiel #16
0
class ReportEntryForm(forms.ModelForm):
    phone_number = PhoneNumberField(
        label="Phone number required for credit.",
        widget=PhoneNumberInternationalFallbackWidget(attrs={"class": "form-control"}),
        required=False,
    )
    description = forms.Textarea()

    class Meta:
        model = ReportEntry
        fields = ("phone_number", "description", "photo_upload")
Beispiel #17
0
 class Meta:
     model = Group
     exclude = ('slug','signup_date','status','point')
     widgets = {
         'rep_phone': PhoneNumberInternationalFallbackWidget(),
         'last_meeting': forms.DateInput(),
         'description': forms.Textarea(attrs={'rows':'5'}),
         'other_social': forms.Textarea(attrs={'rows':'2'}),
         'other_issues': forms.Textarea(attrs={'rows':'4'}),
         'constituency': forms.Textarea(attrs={'rows':'3'}),
         'issues': forms.CheckboxSelectMultiple
     }
Beispiel #18
0
class PersonWithResponsibilitiesForm(PatchedErrorListForm):
    phone = AcPhoneNumberField(
        initial="",
        region=settings.PHONENUMBER_DEFAULT_REGION,
        widget=PhoneNumberInternationalFallbackWidget(
            region=settings.PHONENUMBER_DEFAULT_REGION),
        required=False,
    )

    class Meta:
        model = PersonWithResponsibilities
        exclude = ["id"]
Beispiel #19
0
class ProfileForm(forms.ModelForm):
    mobile_number = PhoneNumberField(
        widget=PhoneNumberInternationalFallbackWidget(region='NG'))
    date_of_birth = forms.DateField(
        widget=SelectDateWidget(years=range(datetime.date.today().year - 40,
                                            datetime.date.today().year)),
        initial=datetime_safe.date.today())

    class Meta:
        model = Profile
        fields = ('date_of_birth', 'picture', 'institution',
                  'NYSC_call_up_number', 'state_code_number', 'mobile_number',
                  'state_of_service')
Beispiel #20
0
class EnterpriseManagerForm(forms.Form):
    username = forms.CharField(required=True, widget=forms.TextInput(attrs={'class': 'form-control'}))
    email = forms.CharField(widget=forms.EmailInput(attrs={'class': 'form-control'}), required=True)
    phone = forms.CharField(widget=PhoneNumberInternationalFallbackWidget(attrs={
        'class': 'form-control',
        'data-mask': '+38 (999) 999-99-99'
    }), label="Контактный телефон")
    password = forms.CharField(widget=forms.PasswordInput(attrs={'class': 'form-control'}))
    password2 = forms.CharField(widget=forms.PasswordInput(attrs={'class': 'form-control'}))

    def __init__(self, *args, **kwargs):
        super(EnterpriseManagerForm, self).__init__(*args, **kwargs)

    def clean_password2(self):
        password = self.cleaned_data['password']
        password2 = self.cleaned_data['password2']
        if password and password2 and password != password2:
            raise ValidationError('Password must be confirm!')
        return password2

    def clean_username(self):
        username = self.cleaned_data['username']
        qs = get_user_model().objects.filter(username__iexact=username)
        if qs.exists():
            raise ValidationError('This username already exists!')
        return username

    def clean_email(self):
        email = self.cleaned_data['email']
        qs = get_user_model().objects.filter(email__iexact=email)
        if qs.exists():
            raise ValidationError('This email already exists!')
        return email

    def clean_phone(self):
        phone = self.cleaned_data['phone']
        qs = get_user_model().objects.filter(phone__iexact=phone)
        if qs.exists():
            raise ValidationError('This email already exists!')
        return phone

    def save(self):
        username = self.cleaned_data.get('username', '')
        email = self.cleaned_data.get('email', '')
        phone = self.cleaned_data.get('phone', '')
        password = self.cleaned_data.get('password', '')
        manager = True
        new_user = get_user_model().objects.create_user(username=username, phone=phone, email=email, manager=manager)
        new_user.set_password(password)
        new_user.save()
        Enterprise.objects.create(owner=new_user)
Beispiel #21
0
    class Meta:
        model = Profile
        fields = [
            'gender', 'first_name', 'last_name', 'common_name', 'phone_number',
            'entrance_year', 'entrance_field', 'entrance_school',
            'professional_status', 'status_school', 'proof_school',
            'annuaire_papier', 'bulletin_papier'
        ]

        widgets = {
            'phone_number': PhoneNumberInternationalFallbackWidget(),
            'annuaire_papier': forms.RadioSelect,
            'bulletin_papier': forms.RadioSelect
        }
Beispiel #22
0
class StudentForm(forms.ModelForm):
    first_name = forms.CharField(max_length=30, label='First name of student')
    second_name = forms.CharField(max_length=30, label='Second name of student')
    gender = forms.IntegerField(widget=forms.RadioSelect(
        choices=CHOICES_GENDER, attrs={'class': 'radio-control'}))
    phone = PhoneNumberField(widget=PhoneNumberInternationalFallbackWidget(), required=False)
    district = forms.ModelChoiceField(queryset=District.objects.all())

    class Meta:
        model = Student
        fields = '__all__'
        widgets = {
            'birthday': widgets.AdminDateWidget(),
            'start_date': widgets.AdminDateWidget(),
        }
    def __init__(self, *args, **kwargs):
        super(OrderForm, self).__init__(*args, **kwargs)
        self.fields['requester_name'].label = "Your full name"
        self.fields['requester_email'].label = "Your email address"
        self.fields['requester_phone_number'].label = "Your phone number"
        self.fields['quantity'].label = "Number of pounds of blueberries"
        self.fields[
            'requester_phone_number'].widget = PhoneNumberInternationalFallbackWidget(
                region='us')
        self.fields['pickup_date'].widget = \
            DateTimePicker(options={"format": "MM/DD/YYYY"})
        self.fields['pickup_date'].validators = [
            after_yesterday, is_during_the_season
        ]
        time_choices = [(None, "Approximate pickup time"), *Order.TIME_CHOICES]
        self.fields['pickup_time'] = ChoiceField(choices=time_choices,
                                                 required=True)

        if settings.DEBUG:
            self.fields['quantity'].initial = 1000
            self.fields['requester_name'].initial = "Bernard"
            self.fields['requester_email'].initial = "*****@*****.**"
            self.fields['requester_phone_number'].initial = "5035555678"
            self.fields['pickup_date'].initial = "09/14/2020"
            self.fields['pickup_time'].initial = 8

        self.helper = FormHelper()
        self.helper.form_method = 'POST'
        self.helper.form_action = 'submit_survey'
        self.helper.form_class = 'form-inline'
        self.helper.field_template = 'bootstrap3/layout/inline_field.html'
        self.helper.layout = Layout(*self.fields.keys())
        order = kwargs.get('instance', None)
        if order:
            if order.status == "CANCELED":
                for field_name in self.fields.keys():
                    self.fields[field_name].widget.attrs['readonly'] = True
            else:
                self.helper.add_input(
                    Button('cancel',
                           "Cancel Order",
                           onclick="window.location.href='{}';".format(
                               reverse('cancel_order',
                                       kwargs={"order_id": order.id}))))
                self.helper.add_input(Submit('submit', "Update Order"))

        else:
            self.helper.add_input(Submit('submit', "Submit"))
Beispiel #24
0
 class Meta:
     model = User
     fields = ['phone_number', 'first_name']
     widgets = {
         'phone_number':
         PhoneNumberInternationalFallbackWidget(
             attrs={
                 'id': 'phone',
                 'class': 'mdc-text-field__input'
             }),
         'first_name':
         forms.TextInput(attrs={
             'id': 'name',
             'class': 'mdc-text-field__input'
         }),
     }
Beispiel #25
0
    def test_fallback_widget_switches_between_national_and_international(self):
        region, number_string = self.local_numbers[0]
        number = PhoneNumber.from_string(number_string, region=region)
        gb_widget = PhoneNumberInternationalFallbackWidget(region='GB')
        de_widget = PhoneNumberInternationalFallbackWidget(region='DE')
        self.assertEqual(
            gb_widget.render("number", number),
            u'<input name="number" type="text" value="01606 75178" />')
        self.assertEqual(
            de_widget.render("number", number),
            u'<input name="number" type="text" value="+44 1606 75178" />')

        # If there's been a validation error, the value should be included verbatim
        self.assertEqual(gb_widget.render("number", "error"),
                         u'<input name="number" type="text" value="error" />')
Beispiel #26
0
 class Meta:
     model = Group
     fields = [
         'name',
         'group_id',
         'description',
         'city',
         'state',
         'county',
         'country',
         'postal_code',
         'size',
         'rep_email',
         'group_contact_email',
         'rep_first_name',
         'rep_last_name',
         'rep_phone',
         'rep_postal_code',
         'website_url',
         'facebook_url',
         'twitter_url',
         'instagram_url',
         'other_social',
         'types_of_organizing',
         'other_types_of_organizing',
         'issues',
         'other_issues',
         'constituency',
         'last_meeting',
         'recurring_meeting',
         'meeting_address_line1',
         'meeting_address_line2',
         'meeting_city',
         'meeting_state_province',
         'meeting_postal_code',
         'meeting_country',
     ]
     widgets = {
         'rep_phone': PhoneNumberInternationalFallbackWidget(),
         'last_meeting': forms.DateInput(),
         'description': forms.Textarea(attrs={'rows': '2'}),
         'other_social': forms.Textarea(attrs={'rows': '2'}),
         'other_issues': forms.Textarea(attrs={'rows': '2'}),
         'constituency': forms.Textarea(attrs={'rows': '2'}),
         'issues': forms.CheckboxSelectMultiple
     }
Beispiel #27
0
 class Meta:
     model = Case
     fields = [
         'divisions', 'client_name', 'client_email', 'client_phone',
         'client_SID', 'open_date', 'incident_description',
         'intake_caseworker', 'referrer'
     ]
     widgets = {
         'client_phone':
         PhoneNumberInternationalFallbackWidget(),
         'incident_description':
         TinyMCE(mce_attrs=TINY_MCE_SETUP),
         'intake_caseworker':
         forms.HiddenInput(),
         'referrer':
         AutocompleteSelect(rel=Tag.cases.rel, admin_site=admin_site),
     }
Beispiel #28
0
class SignUpForm(UserCreationForm):
    username = forms.CharField(widget=forms.TextInput(
        attrs={
            "placeholder": "Username",
            "class": "form-control"
        }))
    email = forms.EmailField(widget=forms.EmailInput(attrs={
        "placeholder": "Email",
        "class": "form-control"
    }))
    phone_number = PhoneNumberField(
        widget=PhoneNumberInternationalFallbackWidget(attrs={
            "placeholder": "Phone Number",
            "class": "form-control"
        }))
    website_name = forms.CharField(widget=forms.TextInput(
        attrs={
            "placeholder": "Website Name",
            "class": "form-control"
        }))
    password1 = forms.CharField(widget=forms.PasswordInput(
        attrs={
            "placeholder": "Password",
            "class": "form-control"
        }))
    password2 = forms.CharField(widget=forms.PasswordInput(
        attrs={
            "placeholder": "Password check",
            "class": "form-control"
        }))

    class Meta:
        model = User
        fields = ('username', 'email', 'password1', 'password2')

    def save(self, commit=True):
        user = super(SignUpForm, self).save(commit=True)
        profile = UserProfile.objects.create(user=user)
        phone_number = self.cleaned_data['phone_number']
        website_name = self.cleaned_data['website_name']
        if phone_number and website_name:
            profile.phone_number = self.cleaned_data['phone_number']
            profile.website_name = self.cleaned_data['website_name']
            profile.save()
        return user
Beispiel #29
0
class EnterpriseCreateForm(forms.ModelForm):
    title = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}),
                            label='Название')
    category = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}),
                               label='Категория')
    phone = forms.CharField(widget=PhoneNumberInternationalFallbackWidget(attrs={
        'class': 'form-control',
        'data-mask': '+38 (999) 999-99-99'
    }), label="Контактный телефон")
    address = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}),
                              label="Адрес")
    description = forms.CharField(widget=forms.Textarea(attrs={'class': 'summernote'}),
                                  label='Описание')
    city = forms.ModelChoiceField(City.objects.all(), widget=forms.Select(attrs={'class': 'form-control'}),
                                  label="Город")

    class Meta:
        model = Enterprise
        exclude = ('owner', 'active_stuff_count', 'group_priority', 'schedule', 'logo', 'active', )
Beispiel #30
0
class loginForm(forms.Form):
    phonenumber = PhoneNumberField(
        widget=PhoneNumberInternationalFallbackWidget(
            attrs={
                "class": "form-control",
                "placeholder": "Phone Number"
            }))
    password = forms.CharField(widget=forms.PasswordInput(
        attrs={
            "class": "form-control",
            "placeholder": "Password"
        }))

    def __init__(self, request, *args, **kwargs):
        self.request = request
        super(loginForm, self).__init__(*args, **kwargs)

    def clean(self):
        request = self.request
        data = self.cleaned_data
        phonenumber = data.get("phonenumber")
        password = data.get("password")
        user = authenticate(request, username=phonenumber, password=password)
        if user is None:
            raise forms.ValidationError(
                "Phone Number and Password do not match. Please try again")
        login(request, user)
        self.user = user
        user_logged_in.send(user.__class__, instance=user, request=request)
        try:
            del request.session['guest_phonenumber_id']
        except:
            pass
        return data

    def clean_phonenumber(self):
        phonenumber = self.cleaned_data.get("phonenumber")
        qs = User.objects.filter(phonenumber=phonenumber)
        if not qs.exists():
            raise forms.ValidationError("Phone Number does not exist")
        return phonenumber
Beispiel #31
0
class OrdinazioneForm(forms.Form):

    nome = forms.CharField(max_length=100,
                           widget=forms.TextInput(attrs={'class': 'col-md-6'}))

    telefono = PhoneNumberField(widget=PhoneNumberInternationalFallbackWidget(
        attrs={'class': 'col-md-6'}))

    email = forms.EmailField(widget=forms.EmailInput(
        attrs={'class': 'col-md-6'}))

    indirizzo = forms.CharField(
        max_length=100,
        widget=forms.TextInput(attrs={'class': 'col-md-6'}),
        initial="Piazza Cahen")
    località = forms.ModelChoiceField(
        queryset=Localita.objects.all(),
        required=False,
        empty_label=None,
        widget=forms.Select(attrs={'class': 'col-md-6'}),
        to_field_name="nome")

    # decomment in production
    # captcha=ReCaptchaField()

    citofono = forms.CharField(
        required=False,
        max_length=100,
        widget=forms.TextInput(attrs={'class': 'col-md-6'}))

    note = forms.CharField(
        required=False,
        widget=forms.Textarea(
            attrs={
                'class':
                'col-12',
                'placeholder':
                "Ad esempio: il citofono non fuziona, accanto al semaforo, "
                "portone all' angolo etc."
            }))
Beispiel #32
0
def prettyphone(value):
    widget = PhoneNumberInternationalFallbackWidget()
    return widget._format_value(value)