Commits

Anonymous committed df26f5d

made simpleemail forms even simpler. no first/last names required

Comments (0)

Files changed (2)

registration/backends/simpleemail/__init__.py

 
         """
         username, email, password = kwargs['username'], kwargs['email'], kwargs['password1']
-        first_name, last_name = kwargs['first_name'], kwargs['last_name']
+        
+        first_name = ''
+        last_name = ''
+        
+        if 'first_name' in kwargs and 'last_name' in kwargs:
+            first_name, last_name = kwargs['first_name'], kwargs['last_name']
 
         if Site._meta.installed:
             site = Site.objects.get_current()

registration/forms.py

                                                                maxlength=75)),
                              label=_("E-mail"))
     password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
-                                label=_("Password"))
+                                label=_("Choose Password"))
     password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
                                 label=_("Password (again)"))
     
     username = forms.CharField(widget=forms.HiddenInput, max_length=75, required=False)
 
     email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict, maxlength=75)),
-                             label=_("E-mail / Username"))
+                             label=_("E-mail"))
 
     first_name = forms.CharField(widget=forms.TextInput(attrs=dict(attrs_dict, maxlength=30)))
 
         # see discussion at http://stackoverflow.com/questions/913589/django-forms-inheritance-and-order-of-form-fields
         
         super(RegistrationFormNoUserName, self).__init__(*args, **kwargs)
+        self.fields.keyOrder = ['email', 'password1', 'password2']
+
+
+class RegistrationFormNoUserNameWithFirstLast(RegistrationFormNoUserName):
+    first_name = forms.CharField(widget=forms.TextInput(attrs=dict(attrs_dict, maxlength=30)))
+
+    last_name = forms.CharField(widget=forms.TextInput(attrs=dict(attrs_dict, maxlength=30)))
+
+    def __init__(self, *args, **kwargs):
+        # reorder the fields
+        # see discussion at http://stackoverflow.com/questions/913589/django-forms-inheritance-and-order-of-form-fields
+        
+        super(RegistrationFormNoUserName, self).__init__(*args, **kwargs)
         self.fields.keyOrder = ['email', 'first_name', 'last_name', 'password1', 'password2']
 
 #