class RegisterEmailAddress(forms.Form): email_address = forms.EmailField(label=ugettext_lazy(u'Email address')) captcha = sphutils.CaptchaField( widget=sphutils.CaptchaWidget, help_text=ugettext_lazy( u'Please enter the result of the above calculation.'), ) def __init__(self, *args, **kwargs): super(RegisterEmailAddress, self).__init__(*args, **kwargs) if not sphutils.has_captcha_support( ) or not sphsettings.get_sph_setting( 'community_register_require_captcha', False): del self.fields['captcha'] def clean(self): if 'email_address' not in self.cleaned_data: return self.cleaned_data if User.objects.filter( email__exact=self.cleaned_data['email_address']).exists(): raise forms.ValidationError( ugettext( u"Another user is already registered with the email address %(email)s." ) % {'email': self.cleaned_data['email_address']}) return self.cleaned_data
class PostForm(forms.Form): subject = forms.CharField(label=_(u"Subject")) body = forms.CharField(label=_(u"Body"), widget=forms.Textarea(attrs={'rows': 10, 'cols': 70}), help_text=describe_render_choices(), ) markup = forms.CharField(label=_('Markup'), widget=forms.Select(choices=POST_MARKUP_CHOICES, )) captcha = sphutils.CaptchaField(label=_('Captcha'), widget=sphutils.CaptchaWidget, help_text=_(u'Please enter the result of the above calculation.'), ) def __init__(self, *args, **kwargs): super(PostForm, self).__init__(*args, **kwargs) if not sphutils.has_captcha_support() or get_current_user().is_authenticated: del self.fields['captcha'] if len(POST_MARKUP_CHOICES) == 1: del self.fields['markup'] def init_for_category_type(self, category_type, post): """ Called after initialization with the category type instance. Arguments: category_type: the category_type instance of the category. post: the post which is edited (if any) """ pass
def __init__(self, *args, **kwargs): super(CaptchaEditBaseForm, self).__init__(*args, **kwargs) if sphutils.has_captcha_support() and not get_current_user().is_authenticated: self.fields['captcha'] = sphutils.CaptchaField(widget=sphutils.CaptchaWidget, help_text=ugettext( 'Please enter the result of the above calculation.'), ) self.fields['tags'] = TagField(model=WikiSnip, required=False)
class WikiSnipForm(ModelForm): tags = TagField(model=WikiSnip, required=False) captcha = sphutils.CaptchaField(widget=sphutils.CaptchaWidget, help_text=ugettext_lazy(u'Please enter the result of the above calculation.'), ) def __init__(self, *args, **kwargs): super(WikiSnipForm, self).__init__(*args, **kwargs) self.fields['body'].widget.attrs['cols'] = 80 self.fields['body'].widget.attrs['rows'] = 30 if not sphutils.has_captcha_support() or get_current_user().is_authenticated: del self.fields['captcha'] class Meta: model = WikiSnip exclude = ('name', 'group',)
class RevealEmailAddress(forms.Form): captcha = sphutils.CaptchaField( widget=sphutils.CaptchaWidget, help_text=ugettext( 'Please enter the result of the above calculation.'), )