def runtime_data()

in api/views/privaterelay.py [0:0]


def runtime_data(request):
    """Get data needed to present the Relay dashboard to a vistor or user."""
    flags = get_waffle_flag_model().get_all()
    flag_values = [(f.name, f.is_active(request)) for f in flags]
    switches = Switch.get_all()
    switch_values = [(s.name, s.is_active()) for s in switches]
    samples = Sample.get_all()
    sample_values = [(s.name, s.is_active()) for s in samples]
    premium_plans: SP3PlanCountryLangMapping | PlanCountryLangMapping
    phone_plans: SP3PlanCountryLangMapping | PlanCountryLangMapping
    bundle_plans: SP3PlanCountryLangMapping | PlanCountryLangMapping
    if settings.USE_SUBPLAT3:
        premium_plans = get_sp3_country_language_mapping("premium")
        phone_plans = get_sp3_country_language_mapping("phones")
        bundle_plans = get_sp3_country_language_mapping("bundle")
    else:
        premium_plans = get_premium_country_language_mapping()
        phone_plans = get_phone_country_language_mapping()
        bundle_plans = get_bundle_country_language_mapping()
    return Response(
        {
            "FXA_ORIGIN": settings.FXA_BASE_ORIGIN,
            "PERIODICAL_PREMIUM_PRODUCT_ID": settings.PERIODICAL_PREMIUM_PROD_ID,
            "GOOGLE_ANALYTICS_ID": settings.GOOGLE_ANALYTICS_ID,
            "GA4_MEASUREMENT_ID": settings.GA4_MEASUREMENT_ID,
            "BUNDLE_PRODUCT_ID": settings.BUNDLE_PROD_ID,
            "PHONE_PRODUCT_ID": settings.PHONE_PROD_ID,
            "PERIODICAL_PREMIUM_PLANS": get_countries_info_from_request_and_mapping(
                request, premium_plans
            ),
            "PHONE_PLANS": get_countries_info_from_request_and_mapping(
                request, phone_plans
            ),
            "BUNDLE_PLANS": get_countries_info_from_request_and_mapping(
                request, bundle_plans
            ),
            "BASKET_ORIGIN": settings.BASKET_ORIGIN,
            "WAFFLE_FLAGS": flag_values,
            "WAFFLE_SWITCHES": switch_values,
            "WAFFLE_SAMPLES": sample_values,
            "MAX_MINUTES_TO_VERIFY_REAL_PHONE": (
                settings.MAX_MINUTES_TO_VERIFY_REAL_PHONE
            ),
        }
    )