diff --git a/backend/client_config.py b/backend/client_config.py index e003e9a..ecc2da0 100644 --- a/backend/client_config.py +++ b/backend/client_config.py @@ -59,6 +59,10 @@ def get_profiles_with_visibility(client_id): available_profiles = [] + # First, get the profiles assigned to this client in CLIENT_PROFILES + # This is our baseline for backward compatibility + baseline_profiles = get_client_profiles(client_id) + # Get profiles directory profiles_dir = os.path.join(os.path.dirname(__file__), 'profiles') profile_files = glob.glob(os.path.join(profiles_dir, '*.json')) @@ -69,14 +73,23 @@ def get_profiles_with_visibility(client_id): profile_data = json.load(f) profile_id = os.path.basename(profile_file).replace('.json', '') - visibility = profile_data.get('visibility', 'all') - visible_to_clients = profile_data.get('visible_to_clients', []) - # Check if profile should be visible to this client - if visibility == 'all': - available_profiles.append(profile_id) - elif visibility == 'client_specific' and client_id in visible_to_clients: - available_profiles.append(profile_id) + # Check if profile has visibility settings + has_visibility_settings = 'visibility' in profile_data + + if has_visibility_settings: + # Use new visibility system if configured + visibility = profile_data.get('visibility', 'all') + visible_to_clients = profile_data.get('visible_to_clients', []) + + if visibility == 'all': + available_profiles.append(profile_id) + elif visibility == 'client_specific' and client_id in visible_to_clients: + available_profiles.append(profile_id) + else: + # Fall back to CLIENT_PROFILES mapping for backward compatibility + if profile_id in baseline_profiles: + available_profiles.append(profile_id) except (json.JSONDecodeError, FileNotFoundError): continue