Tomáš Ehrlich avatar Tomáš Ehrlich committed 71b0ccf

Added form for registration with email only.

Comments (0)

Files changed (1)

registration/forms.py

                              error_messages={'required': _("You must agree to the terms to register")})
 
 
-class RegistrationFormUniqueEmail(RegistrationForm):
+class UniqueEmailMixin(object):
     """
-    Subclass of ``RegistrationForm`` which enforces uniqueness of
-    email addresses.
+    Mixin which enforces uniqueness of email addresses.
     
     """
     def clean_email(self):
         return self.cleaned_data['email']
 
 
+class RegistrationFormUniqueEmail(RegistrationForm, UniqueEmailMixin):
+    """
+    Subclass of RegistrationForm with unique email.
+
+    """
+
+
+class RegistrationFormEmailOnly(forms.Form, UniqueEmailMixin):
+    """
+    Registration form for quick registration (with email only). Passwords
+    are entered during activation.
+
+    """
+    email = forms.EmailField(max_length=75, label=_('Email'))
+
+    def clean(self):
+        data = self.cleaned_data
+        data['username'] = self.generate_username(data['email'])
+        return data
+
+
 class RegistrationFormNoFreeEmail(RegistrationForm):
     """
     Subclass of ``RegistrationForm`` which disallows registration with
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.