Commits

sandinmyjoints  committed a2307df

Added support for saving first and last names to the auth table.

  • Participants
  • Parent commits fad7080

Comments (0)

Files changed (4)

 dist
 MANIFEST
 _build
-_static
+_static
+build

File registration/backends/default/__init__.py

         class of this backend as the sender.
 
         """
-        username, email, password = kwargs['username'], kwargs['email'], kwargs['password1']
+        username, email, password, first_name, last_name = kwargs['username'], kwargs['email'], kwargs['password1'], kwargs['first_name'], kwargs['last_name']
+        print "in django-registration myclone"
+        
         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, first_name, last_name)
         signals.user_registered.send(sender=self.__class__,
                                      user=new_user,
                                      request=request)

File registration/models.py

         return False
     
     def create_inactive_user(self, username, email, password,
-                             site, send_email=True):
+                             site, first_name="", last_name="", send_email=True):
         """
         Create a new, inactive ``User``, generate a
         ``RegistrationProfile`` and email its activation key to the
         
         """
         new_user = User.objects.create_user(username, email, password)
+        new_user.first_name = first_name
+        new_user.last_name = last_name
         new_user.is_active = False
         new_user.save()
 

File registration/tests/backends.py

         
         """
         environ = {
-            'HTTP_COOKIE': self.cookies,
-            'PATH_INFO': '/',
-            'QUERY_STRING': '',
-            'REMOTE_ADDR': '127.0.0.1',
-            'REQUEST_METHOD': 'GET',
-            'SCRIPT_NAME': '',
-            'SERVER_NAME': 'testserver',
-            'SERVER_PORT': '80',
-            'SERVER_PROTOCOL': 'HTTP/1.1',
-            'wsgi.version': (1,0),
-            'wsgi.url_scheme': 'http',
-            'wsgi.errors': self.errors,
-            'wsgi.multiprocess':True,
-            'wsgi.multithread': False,
-            'wsgi.run_once': False,
-            'wsgi.input': None,
+            'HTTP_COOKIE':      self.cookies,
+            'PATH_INFO':         '/',
+            'QUERY_STRING':      '',
+            'REMOTE_ADDR':       '127.0.0.1',
+            'REQUEST_METHOD':    'GET',
+            'SCRIPT_NAME':       '',
+            'SERVER_NAME':       'testserver',
+            'SERVER_PORT':       '80',
+            'SERVER_PROTOCOL':   'HTTP/1.1',
+            'wsgi.version':      (1,0),
+            'wsgi.url_scheme':   'http',
+            'wsgi.errors':       self.errors,
+            'wsgi.multiprocess': True,
+            'wsgi.multithread':  False,
+            'wsgi.run_once':     False,
             }
         environ.update(self.defaults)
         environ.update(request)
     """
     Test the default registration backend.
 
-    Running these tests successfully will require two templates to be
+    Running these tests successfull will require two templates to be
     created for the sending of activation emails; details on these
     templates and their contexts may be found in the documentation for
     the default backend.
         """
         self.old_activation = getattr(settings, 'ACCOUNT_ACTIVATION_DAYS', None)
         if self.old_activation is None:
-            settings.ACCOUNT_ACTIVATION_DAYS = 7 # pragma: no cover
+            settings.ACCOUNT_ACTIVATION_DAYS = 7
 
     def tearDown(self):
         """
 
         """
         if self.old_activation is None:
-            settings.ACCOUNT_ACTIVATION_DAYS = self.old_activation # pragma: no cover
+            settings.ACCOUNT_ACTIVATION_DAYS = self.old_activation
 
     def test_registration(self):
         """
         """
         new_user = self.backend.register(_mock_request(),
                                          username='bob',
+                                         first_name='bob',
+                                         last_name='last',
                                          email='bob@example.com',
                                          password1='secret')
 
         
         """
         Site._meta.installed = False
+
         new_user = self.backend.register(_mock_request(),
                                          username='bob',
+                                         first_name='bob',
+                                         last_name='last',
                                          email='bob@example.com',
                                          password1='secret')
 
         """
         valid_user = self.backend.register(_mock_request(),
                                            username='alice',
+                                           first_name='bob',
+                                           last_name='last',
                                            email='alice@example.com',
                                            password1='swordfish')
 
         """
         expired_user = self.backend.register(_mock_request(),
                                              username='bob',
+	                                         first_name='bob',
+	                                         last_name='last',
                                              email='bob@example.com',
                                              password1='secret')
 
 
         self.backend.register(_mock_request(),
                               username='bob',
+                              first_name='bob',
+                              last_name='last',
                               email='bob@example.com',
                               password1='secret')
 
 
         new_user = self.backend.register(_mock_request(),
                                          username='bob',
+                                         first_name='bob',
+                                         last_name='last',
                                          email='bob@example.com',
                                          password1='secret')
         profile = RegistrationProfile.objects.get(user=new_user)
 
         new_user = self.backend.register(_mock_request(),
                                          username='bob',
+                                         first_name='bob',
+                                         last_name='last',
                                          email='bob@example.com',
                                          password1='secret')
         new_user.date_joined -= datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS + 1)
         
         alice = self.backend.register(_mock_request(),
                                       username='alice',
+                                      first_name='bob',
+                                      last_name='last',
                                       email='alice@example.com',
                                       password1='swordfish')
         
                                             RegistrationProfile.objects.all())
         self.assertEqual(len(mail.outbox), 2) # No additional email because the account has activated.
 
-    def test_email_send_action_no_sites(self):
-        """
-        Test re-sending of activation emails via admin action when
-        ``django.contrib.sites`` is not installed; the fallback will
-        be a ``RequestSite`` instance.
-        
-        """
-        Site._meta.installed = False
-        admin_class = RegistrationAdmin(RegistrationProfile, admin.site)
-        
-        alice = self.backend.register(_mock_request(),
-                                      username='alice',
-                                      email='alice@example.com',
-                                      password1='swordfish')
-        
-        admin_class.resend_activation_email(_mock_request(),
-                                            RegistrationProfile.objects.all())
-        self.assertEqual(len(mail.outbox), 2) # One on registering, one more on the resend.
-        
-        RegistrationProfile.objects.filter(user=alice).update(activation_key=RegistrationProfile.ACTIVATED)
-        admin_class.resend_activation_email(_mock_request(),
-                                            RegistrationProfile.objects.all())
-        self.assertEqual(len(mail.outbox), 2) # No additional email because the account has activated.
-        Site._meta.installed = True
-
     def test_activation_action(self):
         """
         Test manual activation of users view admin action.
 
         alice = self.backend.register(_mock_request(),
                                       username='alice',
+                                      first_name='bob',
+                                      last_name='last',
                                       email='alice@example.com',
                                       password1='swordfish')
 
         """
         new_user = self.backend.register(_mock_request(),
                                          username='bob',
+                                         first_name='bob',
+                                         last_name='last',
                                          email='bob@example.com',
                                          password1='secret')
 
         """
         new_user = self.backend.register(_mock_request(),
                                          username='bob',
+                                         first_name='bob',
+                                         last_name='last',
                                          email='bob@example.com',
                                          password1='secret')
         
 
         self.backend.register(_mock_request(),
                               username='bob',
+                              first_name='bob',
+                              last_name='last',
                               email='bob@example.com',
                               password1='secret')