class EmailInput(forms.TextInput):
+ """Displays an HTML5 email input on browsers which support it and a normal text input on other browsers."""
input_type = 'email'
class RegistrationForm(UserCreationForm):
+ """
+ Handles user registration. If :mod:`recaptcha_django` is installed on the system and :class:`recaptcha_django.middleware.ReCaptchaMiddleware` is in :setting:`settings.MIDDLEWARE_CLASSES`, then a recaptcha field will automatically be added to the registration form.
+
+ .. seealso:: `recaptcha-django <http://code.google.com/p/recaptcha-django/>`_
+
+ """
+ #: An :class:`EmailField` using the :class:`EmailInput` widget.
email = forms.EmailField(widget=EmailInput)
try:
from recaptcha_django import ReCaptchaField
class UserAccountForm(forms.ModelForm):
+ """Handles a user's account - by default, :attr:`auth.User.first_name`, :attr:`auth.User.last_name`, :attr:`auth.User.email`."""
first_name = User._meta.get_field('first_name').formfield(required=True)
last_name = User._meta.get_field('last_name').formfield(required=True)
email = User._meta.get_field('email').formfield(required=True, widget=EmailInput)
class WaldoAuthenticationForm(AuthenticationForm):
+ """Handles user authentication. Checks that the user has not mistakenly entered their email address (like :class:`django.contrib.admin.forms.AdminAuthenticationForm`) but does not require that the user be staff."""
ERROR_MESSAGE = _("Please enter a correct username and password. Note that both fields are case-sensitive.")
def clean(self):
elif not self.user_cache.is_active:
raise ValidationError(message)
self.check_for_test_cookie()
- return self.cleaned_data
-
- def check_for_test_cookie(self):
- # This method duplicates the Django 1.3 AuthenticationForm method.
- if self.request and not self.request.session.test_cookie_worked():
- raise forms.ValidationError(
- _("Your Web browser doesn't appear to have cookies enabled. "
- "Cookies are required for logging in."))
\ No newline at end of file
+ return self.cleaned_data
\ No newline at end of file