Пример #1
0
    def gen_users():
        nonlocal existing
        logger.info(f"Transferring users")

        users = UsersUser.objects.order_by("id")
        # Only iterate over users that do not exist already

        elapsed, progress = timer_func()

        # Allow limiting the input
        stream = islice(zip(count(1), users), limit)
        for index, user in stream:
            progress(index=index, msg="users")
            # Set the username to twitter id or a default
            # Extra prefix 'username' necessary in default to avoid duplicating
            # from already migrated/populated users: user-1, user-2
            default_username = f'user-{user.id}'
            username = user.profile.twitter_id or default_username
            if username in existing:
                username = f'user-{util.get_uuid(limit=5)}'

            # Create user
            new_user = User(username=username,
                            email=user.email,
                            password=user.password,
                            is_active=user.is_active,
                            is_superuser=user.is_admin,
                            is_staff=user.is_staff)

            current[user.email] = new_user
            existing.append(username)

            yield new_user
Пример #2
0
    def gen_users():
        logger.info(f"Transferring users")

        users = UsersUser.objects.order_by("id")
        # Only iterate over users that do not exist already

        elapsed, progress = timer_func()

        # Allow limiting the input
        stream = islice(zip(count(1), users), LIMIT)

        for index, user in stream:
            progress(index, msg="users")
            username = f"{user.name}{user.id}"
            # Create user
            user = User(username=username, email=user.email, password=user.password,
                        is_active=user.is_active, is_superuser=user.is_admin, is_staff=user.is_staff)
            yield user
Пример #3
0
    def gen_users():

        logger.info(f"Transferring users")

        elapsed, progress = timer_func()

        # Allow limiting the input
        stream = islice(zip(count(1), old_users), limit)
        for index, user in stream:
            progress(index=index,  msg="users")

            username = f"{user.name.replace(' ', '-')}-{user.id}"
            # Create user
            new_user = User(username=username, email=user.email, password=user.password,
                            is_active=user.is_active, is_superuser=user.is_admin, is_staff=user.is_staff)

            current[user.email] = new_user

            yield new_user