def firefox_url()

in bedrock/firefox/templatetags/helpers.py [0:0]


def firefox_url(platform, page, channel=None):
    """
    Return a product-related URL like /firefox/all/ or /mobile/beta/notes/.

    Examples
    ========

    In Template
    -----------

        {{ firefox_url('desktop', 'all', 'organizations') }}
        {{ firefox_url('desktop', 'sysreq', channel) }}
        {{ firefox_url('android', 'notes') }}
    """

    kwargs = {}

    # Tweak the channel name for the naming URL pattern in urls.py
    if channel == "release":
        channel = None
    if channel == "alpha":
        if platform == "desktop":
            channel = "developer"
        if platform == "android":
            channel = "aurora"
    if channel == "esr":
        channel = "organizations"

    # There is now only one /all page URL - issue 8096
    if page == "all":
        if platform == "desktop":
            if channel == "beta":
                product = "desktop-beta"
            elif channel == "developer":
                product = "desktop-developer"
            elif channel == "nightly":
                product = "desktop-nightly"
            elif channel == "organizations":
                product = "desktop-esr"
            else:
                product = "desktop-release"
        elif platform == "android":
            if channel == "beta":
                product = "android-beta"
            elif channel == "nightly":
                product = "android-nightly"
            else:
                product = "android-release"
    else:
        if channel:
            kwargs["channel"] = channel
        if platform != "desktop":
            kwargs["platform"] = platform

    # Firefox for Android and iOS have the system requirements page on SUMO
    if platform in ["android", "ios"] and page == "sysreq":
        return settings.FIREFOX_MOBILE_SYSREQ_URL

    if page == "all" and product:
        kwargs["product_slug"] = product
        return reverse("firefox.all.platforms", kwargs=kwargs)

    return reverse(f"firefox.{page}", kwargs=kwargs)