Beispiel #1
0
class NewCaseForm(forms.ModelForm):

    recaptcha = RecaptchaField(label='Captcha', required=True)

    class Meta:
        model = SuccessCase
        exclude = ('slug', )
Beispiel #2
0
class LoginForm(forms.Form):
   
    username =forms.CharField(max_length=30)
    password = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
                                label=_(u'password'))
    
    recaptcha = RecaptchaField(label='We are not allow any automated system', required=True)
Beispiel #3
0
class SafeClassicRegisterForm(ClassicRegisterForm):
    """this form uses recaptcha in addition
    to the base register form
    """
    recaptcha = RecaptchaField(
        private_key=openode_settings.RECAPTCHA_SECRET,
        public_key=openode_settings.RECAPTCHA_KEY
    )
Beispiel #4
0
class RegisterForm(forms.Form):
    username = forms.RegexField(label="Username",
                                regex=r'^\w+$',
                                min_length=2,
                                max_length=30)
    password1 = forms.CharField(label="Password",
                                min_length=4,
                                widget=forms.PasswordInput(render_value=False),
                                help_text="At least 4 chars long")
    password2 = forms.CharField(label="Password (again)",
                                min_length=4,
                                widget=forms.PasswordInput(render_value=False))
    email1 = forms.EmailField(
        label="E-mail address",
        help_text="We won't share this to any 3rd-parties!")
    email2 = forms.EmailField(label="E-mail address (again)")

    if get_config('ENABLE_CAPTCHA', False):
        if not (get_config('RECAPTCHA_PUBLIC_KEY', False)
                and get_config('RECAPTCHA_PRIVATE_KEY', False)):
            raise ImproperlyConfigured(
                "You must define the RECAPTCHA_PUBLIC_KEY"
                " and/or RECAPTCHA_PRIVATE_KEY setting in order to use reCAPTCHA."
            )
        recaptcha = RecaptchaField(label="Human test", required=True)

    def clean_username(self):
        username = self.cleaned_data.get('username')
        try:
            user = User.objects.get(username__iexact=username)
            del user
            raise forms.ValidationError("Username is already taken")
        except User.DoesNotExist:
            pass
        return username

    def clean_password2(self):
        password1 = self.cleaned_data.get('password1')
        password2 = self.cleaned_data.get('password2')
        if password1 != password2:
            raise forms.ValidationError(
                "You must type the same password each time")
        return password2

    def clean_email2(self):
        email1 = self.cleaned_data.get('email1')
        email2 = self.cleaned_data.get('email2')
        if email1 != email2:
            raise forms.ValidationError(
                "You must type the same e-mail address each time")
        return email2

    def save(self):
        return User.objects.create_user(self.cleaned_data.get('username'),
                                        self.cleaned_data.get('email1'),
                                        self.cleaned_data.get('password1'))
Beispiel #5
0
class PasswordResetForm(forms.Form):
    username = forms.CharField()
    email = forms.EmailField()
    recaptcha = RecaptchaField(label='Human test', required=True)

    def clean_email(self):
        if not User.objects.filter(username=self.data['username'],
                                   email=self.data['email']):
            raise forms.ValidationError('Email doesn\'t match username.')
        return self.data['email']

    def clean(self, *args, **kwargs):
        self.clean_email()
        return super(PasswordResetForm, self).clean(*args, **kwargs)
Beispiel #6
0
class SignUpForm(forms.Form):
    username = UserField(max_length=16)
    password = forms.CharField(widget=forms.PasswordInput())
    password2 = forms.CharField(widget=forms.PasswordInput(),
                                label="Repeat password")
    email = forms.EmailField(required=False)
    recaptcha = RecaptchaField(label='Human test', required=True)

    def clean_password(self):
        if self.data['password'] != self.data['password2']:
            raise forms.ValidationError('Passwords do not match.')
        return self.data['password']

    def clean(self, *args, **kwargs):
        self.clean_password()
        return super(SignUpForm, self).clean(*args, **kwargs)
Beispiel #7
0
class NotARobotForm(forms.Form):
    recaptcha = RecaptchaField(private_key=askbot_settings.RECAPTCHA_SECRET,
                               public_key=askbot_settings.RECAPTCHA_KEY)
Beispiel #8
0
class FeedbackForm(ModelForm):
    recaptcha = RecaptchaField(label='Human test', required=True)

    class Meta:
        model = Feedback
        widgets = {'comment': Textarea(attrs={'cols': 52, 'rows': 5})}
Beispiel #9
0
 def _add_recaptcha_field(self):
     self.fields['recaptcha'] = RecaptchaField(
         private_key=askbot_settings.RECAPTCHA_SECRET,
         public_key=askbot_settings.RECAPTCHA_KEY)
Beispiel #10
0
class reCaptchaContactForm(ContactForm):
    """
    Contact form with a recatpcha-field added based on recaptcha_works.
    """
    captcha = RecaptchaField()
Beispiel #11
0
class RecaptchaForm(forms.ModelForm):

    recaptcha = RecaptchaField(label=_("Prove you're human"))