예제 #1
0
 class CheckboxAttrForm(forms.Form):
     captcha = fields.ReCaptchaField(
         widget=widgets.ReCaptchaV2Checkbox(attrs={
             "data-theme": "dark",
             "data-callback": "customCallback",
             "data-size": "compact"
         },
                                            api_params={"hl": "af"}))
예제 #2
0
 class InvisAttrForm(forms.Form):
     captcha = fields.ReCaptchaField(
         widget=widgets.ReCaptchaV3(attrs={
             "data-theme": "dark",
             "data-callback": "customCallbackInvis",
             "data-size": "compact"
         },
                                    api_params={"hl": "cl"}))
예제 #3
0
파일: forms.py 프로젝트: vtamara/lernanta
class ComposeForm(MessagesComposeForm):
    recipient = UserField()
    recaptcha = captcha_fields.ReCaptchaField()

    def __init__(self, sender=None, *args, **kwargs):
        self.sender = sender
        super(ComposeForm, self).__init__(*args, **kwargs)
        if not settings.RECAPTCHA_PRIVATE_KEY:
            del self.fields['recaptcha']
예제 #4
0
class UserLoginForm(AuthenticationForm):
    username = forms.CharField(
        label='Имя аккаунта',
        widget=forms.TextInput(attrs={'class': 'form-control'}))
    password = forms.CharField(
        label='Пароль',
        widget=forms.PasswordInput(attrs={'class': 'form-control'}))

    captcha = fields.ReCaptchaField(label='Капча',
                                    widget=widgets.ReCaptchaV2Checkbox())

    class Meta:
        model = User
        fields = ('username', 'password')
예제 #5
0
class RegisterForm(forms.Form):

    fullname = forms.CharField(max_length=1000,
                               required=True,
                               widget=forms.TextInput(attrs={
                                   "id": "fullname",
                                   "name": "fullname"
                               }))
    email = forms.EmailField(widget=forms.EmailInput(attrs={
        "id": "email",
        "name": "email"
    }),
                             required=True)
    mobile = forms.CharField(max_length=20,
                             widget=forms.TextInput(attrs={
                                 "id": "mobile",
                                 "name": "mobile"
                             }),
                             required=True)
    company = forms.CharField(max_length=100,
                              widget=forms.TextInput(attrs={
                                  "id": "company",
                                  "name": "company"
                              }),
                              required=True)
    domain = forms.CharField(max_length=100,
                             widget=forms.TextInput(attrs={
                                 "id": "domain",
                                 "name": "domain"
                             }),
                             required=True)
    username = forms.CharField(max_length=500,
                               widget=forms.TextInput(attrs={
                                   "id": "username",
                                   "name": "username"
                               }),
                               required=True)
    password = forms.CharField(widget=forms.PasswordInput(attrs={
        "id": "password",
        "name": "password"
    }),
                               required=True)
    confirm = forms.CharField(widget=forms.PasswordInput(attrs={
        "id": "confirm",
        "name": "confirm"
    }),
                              required=True)
    captcha = recaptcha.ReCaptchaField()
예제 #6
0
파일: forms.py 프로젝트: waytai/batucada
class CreateProfileForm(forms.ModelForm):
    recaptcha = captcha_fields.ReCaptchaField()

    class Meta:
        model = UserProfile
        fields = ('username', 'display_name', 'bio', 'image', 'newsletter',
                  'email')
        widgets = {
            'username': forms.TextInput(attrs={'autocomplete': 'off'}),
        }

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

        if not settings.RECAPTCHA_PRIVATE_KEY:
            del self.fields['recaptcha']
예제 #7
0
class SignupForm(forms.Form):

    name = forms.CharField(
        max_length=200,
        label="Name",
        widget=forms.TextInput(attrs={"placeholder": "Name"}),
        validators=[validate_sluggable_name],
    )
    is_public = forms.BooleanField(
        required=False, label="Show my profile to the public", initial=True
    )
    captcha = fields.ReCaptchaField(label="")

    field_order = ["name", "email", "password1", "password2", "is_public", "captcha"]

    def signup(self, request, user):
        is_public = self.cleaned_data["is_public"]
        name = self.cleaned_data["name"]
        Profile.objects.create(user=user, is_public=is_public, name=name)
예제 #8
0
class UserRegisterForm(UserCreationForm):
    username = forms.CharField(label='Имя аккаунта',
                               max_length=18,
                               widget=forms.TextInput(attrs={
                                   'class': 'form-control',
                                   'autocomplete': 'off'
                               }))

    password1 = forms.CharField(
        label='Пароль',
        widget=forms.PasswordInput(attrs={'class': 'form-control'}))
    password2 = forms.CharField(
        label='Подтвердите пароль',
        widget=forms.PasswordInput(attrs={'class': 'form-control'}))

    captcha = fields.ReCaptchaField(label='Капча',
                                    widget=widgets.ReCaptchaV2Checkbox())

    class Meta:
        model = User
        fields = ('username', 'password1', 'password2')
예제 #9
0
class CreateProfileForm(forms.ModelForm):
    recaptcha = captcha_fields.ReCaptchaField()

    class Meta:
        model = UserProfile
        fields = ('username', 'full_name', 'bio', 'image', 'newsletter',
                  'email')
        widgets = {
            'username': forms.TextInput(attrs={'autocomplete': 'off'}),
        }

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

        if not settings.RECAPTCHA_PRIVATE_KEY:
            del self.fields['recaptcha']

    def clean(self):
        super(CreateProfileForm, self).clean()
        data = self.cleaned_data
        validate_user_identity(self, data)
        return data
예제 #10
0
파일: forms.py 프로젝트: thornet/batucada
class RegisterForm(forms.ModelForm):
    username = UsernameField()
    password = forms.CharField(
        max_length=255,
        widget=forms.PasswordInput(render_value=False))
    password_confirm = forms.CharField(
        max_length=255,
        widget=forms.PasswordInput(render_value=False))
    recaptcha = captcha_fields.ReCaptchaField()

    class Meta:
        model = UserProfile
        widgets = {
            'username': forms.TextInput(attrs={'autocomplete': 'off'}),
        }

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

        if not settings.RECAPTCHA_PRIVATE_KEY:
            del self.fields['recaptcha']

    def clean_password(self):
        password = self.cleaned_data['password']
        message = check_password_complexity(password)
        if message:
            self._errors['password'] = forms.util.ErrorList([message])
        return password

    def clean(self):
        """Ensure password and password_confirm match."""
        super(RegisterForm, self).clean()
        data = self.cleaned_data
        if 'password' in data and 'password_confirm' in data:
            if data['password'] != data['password_confirm']:
                self._errors['password_confirm'] = forms.util.ErrorList([
                    _('Passwords do not match.')])
        return data
예제 #11
0
class ContactForm(forms.Form):
    name = forms.CharField(
        max_length=127,
        required=True,
        label='Your Name',
        widget=forms.TextInput(attrs={'class': 'form-control'}),
    )
    email = forms.EmailField(
        required=True,
        label='Your Email',
        widget=forms.EmailInput(attrs={'class': 'form-control'}),
    )
    subject = forms.CharField(
        max_length=127,
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control'}),
    )
    message = forms.CharField(
        required=True,
        widget=forms.Textarea(attrs={'class': 'form-control'}),
    )
    captcha = fields.ReCaptchaField(
        widget=widgets.ReCaptchaV2Checkbox()
    )

    def save(self):
        email = EmailMessage(
            self.cleaned_data['subject'],
            self.cleaned_data['message'],
            f"{self.cleaned_data['name']} <{self.cleaned_data['email']}>",
            ['*****@*****.**'],
            reply_to=[self.cleaned_data['email']]
        )
        try:
            email.send(fail_silently=False)
            return True, ''
        except Exception as e:
            return False, e
예제 #12
0
class TestWizardRecaptchaForm(forms.Form):
    charfield = forms.CharField()
    captcha = fields.ReCaptchaField(wizard_persist_is_valid=True)
class TestForm(Form):
    captcha = fields.ReCaptchaField(attrs={'theme': 'white'})
예제 #14
0
 class ImporperForm(forms.Form):
     captcha = fields.ReCaptchaField()
예제 #15
0
 class DefaultCheckForm(forms.Form):
     captcha = fields.ReCaptchaField()
class RecaptchaForm(Form):
    captcha = fields.ReCaptchaField()
예제 #17
0
 class ImporperForm(forms.Form):
     captcha = fields.ReCaptchaField(widget=forms.Textarea)
예제 #18
0
 class NonDefaultForm(forms.Form):
     captcha = fields.ReCaptchaField(private_key="NewUpdatedKey",
                                     public_key="NewPubKey")
예제 #19
0
 class VThreeDomainForm(forms.Form):
     captcha = fields.ReCaptchaField(widget=widgets.ReCaptchaV3())
예제 #20
0
 class InvisForm(forms.Form):
     captcha = fields.ReCaptchaField(widget=widgets.ReCaptchaV3())
예제 #21
0
class CaptchaForm(forms.Form):
    captcha = fields.ReCaptchaField(attrs={'lang': 'zh-TW'})
예제 #22
0
 class VThreeDomainForm(forms.Form):
     captcha = fields.ReCaptchaField(widget=widgets.ReCaptchaV3(
         attrs={'required_score': 0.8}))
예제 #23
0
class TestForm(Form):
    captcha = fields.ReCaptchaField(attrs={'lang': 'zh-TW'})
예제 #24
0
    captcha = ReCaptchaField(widget=ReCaptchaV2Invisible)


captcha = ReCaptchaField(
    public_key='6Lcb8uMUAAAAAAuiV5Ybj5CegQZzoUcx6FeHLm1C',
    private_key='6Lcb8uMUAAAAAPx4sL7qgZFp3AuwYUWAJ17uTVpy',
)


class FormWithCaptcha(forms.Form):
    captcha = ReCaptchaField(widget=ReCaptchaV2Invisible)


captcha = fields.ReCaptchaField(widget=widgets.ReCaptchaV2Checkbox(
    attrs={
        'data-theme': 'dark',
        'data-size': 'compact',
    }))
# The ReCaptchaV2Invisible widget
# ignores the "data-size" attribute in favor of 'data-size="invisible"'

captcha = fields.ReCaptchaField(widget=widgets.ReCaptchaV2Checkbox(
    api_params={
        'hl': 'cl',
        'onload': 'onLoadFunc'
    }))
# The dictionary is urlencoded and appended to the reCAPTCHA api url.

captcha = fields.ReCaptchaField(widget=ReCaptchaV2Invisible(
    attrs={
        'required_score': 0.85,
예제 #25
0
 class DomainForm(forms.Form):
     captcha = fields.ReCaptchaField(
         widget=widgets.ReCaptchaV2Checkbox())
예제 #26
0
파일: forms.py 프로젝트: mkcode/lernanta
class RegisterForm(forms.ModelForm):
    username = UsernameField()
    full_name = forms.CharField(max_length=255, required=False)
    password = forms.CharField(max_length=128,
                               widget=forms.PasswordInput(render_value=False))
    password_confirm = forms.CharField(
        max_length=128, widget=forms.PasswordInput(render_value=False))
    preflang = forms.CharField(
        max_length=3,
        widget=forms.Select(choices=settings.SUPPORTED_LANGUAGES),
        initial=settings.LANGUAGE_CODE)
    recaptcha = captcha_fields.ReCaptchaField()
    email_confirm = forms.EmailField(max_length=75)

    class Meta:
        model = User
        fields = ('username', 'email', 'preflang')
        widgets = {
            'username': forms.TextInput(attrs={'autocomplete': 'off'}),
        }

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

        if not settings.RECAPTCHA_PRIVATE_KEY:
            del self.fields['recaptcha']

    def clean_password(self):
        password = self.cleaned_data['password']
        message = check_password_complexity(password)
        if message:
            self._errors['password'] = forms.util.ErrorList([message])
        return password

    def clean_username(self):
        username = self.cleaned_data['username']
        if UserProfile.objects.filter(username=username).exists():
            raise forms.ValidationError(
                _('User profile with this Username already exists.'))
        return username

    def clean_email(self):
        email = self.cleaned_data['email']
        if not email or not email.strip():
            raise forms.ValidationError(_('This field is required.'))
        if UserProfile.objects.filter(email=email).exists():
            raise forms.ValidationError(
                _('User profile with this Email already exists.'))
        return email

    def clean(self):
        super(RegisterForm, self).clean()
        data = self.cleaned_data
        validate_user_identity(self, data)
        if 'password' in data and 'password_confirm' in data:
            if data['password'] != data['password_confirm']:
                self._errors['password_confirm'] = forms.util.ErrorList(
                    [_('Passwords do not match.')])
        if 'email' in data and 'email_confirm' in data:
            if data['email'] != data['email_confirm']:
                self._errors['email_confirm'] = forms.util.ErrorList(
                    [_('Email addresses do not match.')])
        if 'full_name' in data:
            data['full_name'] = data['full_name'].strip()
        return data
예제 #27
0
 class InvisDomainForm(forms.Form):
     captcha = fields.ReCaptchaField(
         widget=widgets.ReCaptchaV2Invisible())