def find_matching_internal_user_for_email(request, email):
    matching_users = [user for user in UserProfile.objects.filter(email__startswith=(email.split('@')[0] + '@')).order_by('id') if (not user.is_external)]
    if (not matching_users):
        return None
    if (len(matching_users) > 1):
        raise UserProfile.MultipleObjectsReturned(matching_users)
    return matching_users[0]
def find_matching_internal_user_for_email(request, email):
    matching_users = [user for user in UserProfile.objects.filter(email__startswith=(email.split('@')[0] + '@')).order_by('id') if (not user.is_external)]
    if (not matching_users):
        return None
    if (len(matching_users) > 1):
        raise UserProfile.MultipleObjectsReturned(matching_users)
    return matching_users[0]