def handle(self):
		"""
		The migrate_usernames callback
		"""
		try:
			migrate_usernames()
		except Exception, e:
			raise CommandError(e.message)
Beispiel #2
0
    def forwards(self, orm):
        "Write your forwards methods here."
        # Note: Don't use "from appname.models import ModelName". 
        # Use orm.ModelName to refer to models in this application,
        # and orm['appname.ModelName'] for models in other applications.

        # This will migrate usernames to emails
        # so that users can login with their email.
        migrate_usernames()
 def _test_can_migrate_with_email(self):
     """
     Same outcome required when ALLOW_EMPTY is disabled and enabled
     """
     # Create a user to migrate, with username and email
     user = self.create_src_user(self.username, self.email)
     
     # Migration succeeds
     migrate_usernames(quiet=True)
     
     # User has email hashed as username
     user = User.objects.get(pk=user.pk)
     self.assertEqual(user.username, self.email)
 def test_empty_enabled_can_migrate_without_email(self):
     # Default setting
     settings.ALLOW_EMPTY = True
     
     # Create a user to migrate, with username and no email
     user = self.create_src_user(self.username, '')
     
     # Migration succeeds
     migrate_usernames(quiet=True)
     
     # User has original username and no email
     user = User.objects.get(pk=user.pk)
     self.assertEqual(user.username, self.username)
     self.assertEqual(user.email, '')
 def test_empty_disabled_cant_migrate_without_email(self):
     # Default setting
     settings.ALLOW_EMPTY = False
     
     # Create a user to migrate, with username and no email
     self.create_src_user(self.username, '')
     
     # Migration fails due to missing e-mail
     try:
         migrate_usernames(quiet=True)
     except Exception, e:
         self.assertEqual(
             e.message, 'django-email-as-username migration failed.'
         )
Beispiel #6
0
def migrate_fullhouse_usernames():
    """
        WARNING: RUN THIS SCRIPT BEFORE SOUTH MIGRATIONS OR BAD
        SHIT WILL HAPPEN.

    """

    for user in User.objects.all().order_by('date_joined'):
        email = str(user.email)
        if email in encountered_emails:
            username = user._username
            update_duplicate_email(user)
            send_email_update_notification(user)
            if email in duplicates:
                duplicates[email].append(user.email)
            else:
                duplicates[email] = [user.email]
        else:
            encountered_emails.update([email])

    print "Updated duplicate emails for %d of %d accounts" % (
          sum(len(d) for d in (duplicates.values())), len(encountered_emails))

    migrate_usernames()
 def forwards(self, orm):
     migrate_usernames()
 def forwards(self, orm):
     migrate_usernames()