示例#1
0
    def _from_user_internal(user,
                            full_projection=False,
                            is_coaching_logged_in_user=False,
                            is_self=False):

        profile = UserProfile()

        profile.username = user.username
        profile.nickname = user.nickname
        profile.date_joined = user.joined
        avatar = util_avatars.avatar_for_name(user.avatar_name)
        profile.avatar_name = avatar.name
        profile.avatar_src = avatar.image_src
        profile.public_badges = util_badges.get_public_user_badges(user)
        profile.points = user.points
        profile.count_videos_completed = user.get_videos_completed()
        profile.count_exercises_proficient = len(user.all_proficient_exercises)

        profile.is_self = is_self
        profile.is_coaching_logged_in_user = is_coaching_logged_in_user

        suggested_alternative = SuggestedActivityExperiment.get_alternative_for_user(
                user, is_self) or SuggestedActivityExperiment.NO_SHOW
        show_suggested_activity = (suggested_alternative == SuggestedActivityExperiment.SHOW)

        profile.show_suggested_activity = show_suggested_activity

        profile.is_public = user.has_public_profile()
        if full_projection:
            profile.email = user.email
            profile.is_data_collectible = user.is_certain_to_be_thirteen()

        return profile
示例#2
0
    def _from_user_internal(user,
                            full_projection=False,
                            is_coaching_logged_in_user=False,
                            is_self=False):

        profile = UserProfile()

        profile.username = user.username
        profile.nickname = user.nickname
        profile.date_joined = user.joined
        avatar = util_avatars.avatar_for_name(user.avatar_name)
        profile.avatar_name = avatar.name
        profile.avatar_src = avatar.image_src
        profile.public_badges = util_badges.get_public_user_badges(user)
        profile.points = user.points
        profile.count_videos_completed = user.get_videos_completed()
        profile.count_exercises_proficient = len(user.all_proficient_exercises)

        profile.is_self = is_self
        profile.is_coaching_logged_in_user = is_coaching_logged_in_user
        profile.is_phantom = user.is_phantom

        profile.is_public = user.has_public_profile()

        if profile.is_public or full_projection:
            profile.profile_root = user.profile_root

        if full_projection:
            profile.email = user.email
            profile.is_data_collectible = (not user.is_child_account() and
                                           not user.is_maybe_edu_account())

        return profile
示例#3
0
    def _from_user_internal(user,
                            full_projection=False,
                            is_coaching_logged_in_user=False,
                            is_self=False):

        profile = UserProfile()

        profile.username = user.username
        profile.nickname = user.nickname
        profile.date_joined = user.joined
        avatar = util_avatars.avatar_for_name(user.avatar_name)
        profile.avatar_name = avatar.name
        profile.avatar_src = avatar.image_src
        profile.public_badges = util_badges.get_public_user_badges(user)
        profile.points = user.points
        profile.count_videos_completed = user.get_videos_completed()
        profile.count_exercises_proficient = len(user.all_proficient_exercises)

        profile.is_self = is_self
        profile.is_coaching_logged_in_user = is_coaching_logged_in_user
        profile.is_phantom = user.is_phantom

        profile.is_public = user.has_public_profile()

        if profile.is_public or full_projection:
            profile.profile_root = user.profile_root

        if full_projection:
            profile.email = user.email
            profile.is_data_collectible = (not user.is_child_account()
                                           and not user.is_maybe_edu_account())

        return profile
示例#4
0
    def _from_user_internal(user,
                            full_projection=False,
                            is_coaching_logged_in_user=False,
                            is_self=False):

        profile = UserProfile()

        profile.username = user.username
        profile.nickname = user.nickname
        profile.date_joined = user.joined
        avatar = util_avatars.avatar_for_name(user.avatar_name)
        profile.avatar_name = avatar.name
        profile.avatar_src = avatar.image_src
        profile.public_badges = util_badges.get_public_user_badges(user)
        profile.points = user.points
        profile.count_videos_completed = user.get_videos_completed()
        profile.count_exercises_proficient = len(user.all_proficient_exercises)

        profile.is_self = is_self
        profile.is_coaching_logged_in_user = is_coaching_logged_in_user

        suggested_alternative = SuggestedActivityExperiment.get_alternative_for_user(
            user, is_self) or SuggestedActivityExperiment.NO_SHOW
        show_suggested_activity = (
            suggested_alternative == SuggestedActivityExperiment.SHOW)

        profile.show_suggested_activity = show_suggested_activity

        profile.is_public = user.has_public_profile()
        if full_projection:
            profile.email = user.email
            profile.is_data_collectible = user.is_certain_to_be_thirteen()

        return profile
示例#5
0
    def _from_user_internal(user,
                            full_projection=False,
                            is_coaching_logged_in_user=False,
                            is_parent_of_logged_in_user=False,
                            is_self=False):

        profile = UserProfile()

        # A stranger's public discussion data is fetched by user_key if she
        # does not have a username.
        # TODO(marcia): Backfill usernames so we can remove user_key
        profile.user_key = str(user.key())
        profile.username = user.username
        profile.nickname = user.nickname or user.username or ""
        profile.date_joined = user.joined
        avatar = util_avatars.avatar_for_name(user.avatar_name)
        profile.avatar_name = avatar.name
        profile.avatar_src = avatar.image_src
        profile.public_badges = util_badges.get_public_user_badges(user)
        profile.points = user.points
        profile.count_videos_completed = user.get_videos_completed()
        profile.count_exercises_proficient = len(user.all_proficient_exercises)

        profile.is_self = is_self
        profile.is_coaching_logged_in_user = is_coaching_logged_in_user
        profile.is_parent_of_logged_in_user = is_parent_of_logged_in_user
        profile.is_phantom = user.is_phantom

        profile.is_moderator = user.is_moderator_or_developer

        profile.is_public = user.has_public_profile()

        if profile.is_public or full_projection:
            profile.profile_root = user.profile_root

        if full_projection:
            profile.email = user.email
            profile.is_data_collectible = (not user.is_child_account() and
                                           not user.is_maybe_edu_account())
            profile.is_activity_accessible = True

        return profile