def _has_access_perm_for_obj(user, other_user, access): if (access == UserAccessField.ACCESS_ANYONE): return True if (user.is_authenticated): if (access == UserAccessField.ACCESS_ME): return is_self(user=user, other_user=other_user) if (access == UserAccessField.ACCESS_FRIENDS): return ((is_self(user=user, other_user=other_user)) or (are_friends(user=user, other_user=other_user))) if (access == UserAccessField.ACCESS_FRIENDS_AND_FRIENDS_OF_FRIENDS): return ((is_self(user=user, other_user=other_user)) or (are_friends(user=user, other_user=other_user))) return False
def view_friend_list(user, other_user): # User can view other user's friends only on Speedy Net. # Otherwise (on Speedy Match), user can only view his or her own friends. if (django_settings.SITE_ID == django_settings.SPEEDY_NET_SITE_ID): return True else: return (is_self(user=user, other_user=other_user))
def is_match_profile(user, other_user): if (user.is_authenticated): match_profile = user.speedy_match_profile.get_matching_rank(other_profile=other_user.speedy_match_profile) > SpeedyMatchSiteProfile.RANK_0 has_message = Chat.objects.filter((Q(ent1_id=user) & Q(ent2_id=other_user)) | (Q(ent1_id=other_user) & Q(ent2_id=user))).exists() has_likes = UserLike.objects.filter((Q(from_user=user) & Q(to_user=other_user)) | (Q(from_user=other_user) & Q(to_user=user))).exists() has_blocked = Block.objects.has_blocked(blocker=user, blocked=other_user) return (is_self(user=user, other_user=other_user)) or (match_profile or has_message or has_likes or has_blocked) return False
def is_match_profile(user, other_user): if (user.is_authenticated): match_profile = user.speedy_match_profile.get_matching_rank( other_profile=other_user.speedy_match_profile ) > SpeedyMatchSiteProfile.RANK_0 has_message = Chat.objects.filter( (Q(ent1_id=user) & Q(ent2_id=other_user)) | (Q(ent1_id=other_user) & Q(ent2_id=user))).exists() has_likes = UserLike.objects.filter( (Q(from_user=user) & Q(to_user=other_user)) | (Q(from_user=other_user) & Q(to_user=user))).exists() has_blocked = Block.objects.has_blocked(blocker=user, blocked=other_user) return (is_self( user=user, other_user=other_user)) or (match_profile or has_message or has_likes or has_blocked) return False