Commits

Michael Elsdörfer committed b8fc294

Changed the signature of the Backend.register method, to allow the view (or a custom backend) passing kwargs all the way down to the email sending code.

Comments (0)

Files changed (2)

registration/backends/default/__init__.py

     an instance of ``registration.models.RegistrationProfile``. See
     that model and its custom manager for full documentation of its
     fields and supported operations.
-    
+
     """
-    def register(self, request, **kwargs):
+    def register(self, request, form_data, **kwargs):
         """
-        Given a username, email address and password, register a new
-        user account, which will initially be inactive.
+        Given a username, email address and password (in ``form_data``),
+        register a new user account, which will initially be inactive.
+
+        Additional ``kwargs`` will be passed to the ``create_inactive_user``
+        call.
 
         Along with the new ``User`` object, a new
         ``registration.models.RegistrationProfile`` will be created,
         class of this backend as the sender.
 
         """
-        username, email, password = kwargs['username'], kwargs['email'], kwargs['password1']
+        username, email, password = \
+                form_data['username'], form_data['email'], form_data['password1']
         if Site._meta.installed:
             site = Site.objects.get_current()
         else:
             site = RequestSite(request)
         new_user = RegistrationProfile.objects.create_inactive_user(username, email,
-                                                                    password, site)
+                                                                    password, site,
+                                                                    **kwargs)
         signals.user_registered.send(sender=self.__class__,
                                      user=new_user,
                                      request=request)
         ``registration.signals.user_activated`` will be sent, with the
         newly activated ``User`` as the keyword argument ``user`` and
         the class of this backend as the sender.
-        
+
         """
         activated = RegistrationProfile.objects.activate_user(activation_key)
         if activated:
 
         * If ``REGISTRATION_OPEN`` is both specified and set to
           ``False``, registration is not permitted.
-        
+
         """
         return getattr(settings, 'REGISTRATION_OPEN', True)
 
     def get_form_class(self, request):
         """
         Return the default form class used for user registration.
-        
+
         """
         return RegistrationForm
 
         """
         Return the name of the URL to redirect to after successful
         user registration.
-        
+
         """
         return ('registration_complete', (), {})
 
         """
         Return the name of the URL to redirect to after successful
         account activation.
-        
+
         """
         return ('registration_activation_complete', (), {})

registration/views.py

     if request.method == 'POST':
         form = form_class(data=request.POST, files=request.FILES)
         if form.is_valid():
-            new_user = backend.register(request, **form.cleaned_data)
+            new_user = backend.register(request, form.cleaned_data)
             if on_success:
                 on_success()
             if success_url is None: