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
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
def __init__(self): self.username = None self.email = "" # Indicates whether or not the profile has been marked public. Not # necessarily indicative of what fields are currently filled in this # current instance, as different projections may differ on actor # privileges self.is_public = False # Whether or not the app is able to collect data about the user. # Note users under 13 without parental consent cannot give private data. self.is_data_collectible = False self.is_coaching_logged_in_user = False self.nickname = "" self.date_joined = "" self.points = 0 self.count_videos_completed = 0 self.count_exercises_proficient = 0 self.public_badges = [] default_avatar = util_avatars.avatar_for_name() self.avatar_name = default_avatar.name self.avatar_src = default_avatar.image_src
def __init__(self): self.username = None self.profile_root = "/profile" self.email = "" self.is_phantom = True # Indicates whether or not the profile has been marked public. Not # necessarily indicative of what fields are currently filled in this # current instance, as different projections may differ on actor # privileges self.is_public = False # Whether or not the app is able to collect data about the user. # Note users under 13 without parental consent cannot give private data. self.is_data_collectible = False self.is_coaching_logged_in_user = False self.is_requesting_to_coach_logged_in_user = False self.nickname = "" self.date_joined = "" self.points = 0 self.count_videos_completed = 0 self.count_exercises_proficient = 0 self.public_badges = [] default_avatar = util_avatars.avatar_for_name() self.avatar_name = default_avatar.name self.avatar_src = default_avatar.image_src
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
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
def __init__(self): self.username = None self.profile_root = "/profile" self.email = "" self.is_phantom = True # Indicates whether or not the profile has been marked public. Not # necessarily indicative of what fields are currently filled in this # current instance, as different projections may differ on actor # privileges self.is_public = False # Whether or not the app is able to collect data about the user. # Note users under 13 without parental consent cannot give private # data. self.is_data_collectible = False # Whether or not the data about the user's activity on the site is # available to the viewer of this profile. This includes goals, # video and exercise data. self.is_activity_accessible = False # TODO(benkomalo): extract these one-off variables out into # something nicer that encapsulates relationship with the actor self.is_coaching_logged_in_user = False self.is_requesting_to_coach_logged_in_user = False self.is_parent_of_logged_in_user = False self.is_moderator = False self.nickname = "" self.date_joined = "" self.points = 0 self.count_videos_completed = 0 self.count_exercises_proficient = 0 self.public_badges = [] default_avatar = util_avatars.avatar_for_name() self.avatar_name = default_avatar.name self.avatar_src = default_avatar.image_src