def _is_user_profile_visible(self, user=None):
    try:
        if hasattr(self, 'is_private'):
            # This is an optimization used by the web API. It will set
            # is_private on this User instance through a query, saving a
            # lookup for each instance.
            #
            # This must be done because select_related() and
            # prefetch_related() won't cache reverse foreign key relations.
            is_private = self.is_private
        else:
            is_private = self.get_profile().is_private

        return ((user and (user == self or user.is_staff)) or
                not is_private)
    except Profile.DoesNotExist:
        return True
Get whether or not a User's profile is viewable by a given user.
dataset/ETHPy150Open reviewboard/reviewboard/reviewboard/accounts/models.py/_is_user_profile_visible