Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug 820622: Add locale to download url path in buttons.

  • Loading branch information...
commit d6a8cde94356879e593627004859293b340b52fb 1 parent f7f3e6a
@pmclanahan pmclanahan authored
View
9 apps/mozorg/helpers/download_buttons.py
@@ -23,7 +23,7 @@
download_urls = {
- 'transition': '/products/download.html',
+ 'transition': '/{locale}/products/download.html',
'direct': 'https://download.mozilla.org/',
'aurora': 'https://ftp.mozilla.org/pub/mozilla.org/firefox/'
'nightly/latest-mozilla-aurora',
@@ -120,8 +120,11 @@ def make_download_link(product, build, version, platform, locale,
if locale in settings.LOCALES_WITH_TRANSITION and not force_direct:
src = 'transition'
- return ('%s?product=%s-%s&os=%s&lang=%s' %
- (download_urls[src], product, version, platform, locale))
+ tmpl = '?'.join([download_urls[src], 'product={prod}-{vers}&os={plat}'
+ '&lang={locale}'])
+
+ return tmpl.format(prod=product, vers=version,
+ plat=platform, locale=locale)
@jingo.register.function
View
17 apps/mozorg/tests/test_helper_download_buttons.py
@@ -12,8 +12,9 @@
from product_details import product_details
from pyquery import PyQuery as pq
+from mozorg.helpers.download_buttons import make_download_link
+
-# Where should this function go?
def render(s, context={}):
t = jingo.env.from_string(s)
return t.render(**context)
@@ -46,7 +47,8 @@ def test_button(self, small=False):
rf = RequestFactory()
get_request = rf.get('/fake')
get_request.locale = 'fr'
- doc = pq(render("{{ download_firefox(small=%s, dom_id='button') }}" % small,
+ doc = pq(render("{{ download_firefox(small=%s, "
+ "dom_id='button') }}" % small,
{'request': get_request}))
eq_(doc.attr('id'), 'button')
@@ -175,3 +177,14 @@ def test_stub_aurora_installer_override_locale(self):
links = doc('.download-list a')[:3]
for link in links:
ok_('stub' not in pq(link).attr('href'))
+
+ def test_download_transition_link_contains_locale(self):
+ """
+ "transition" download links should include the locale in the path as
+ well as the query string.
+ """
+ locale = settings.LOCALES_WITH_TRANSITION[0]
+ url = make_download_link('firefox', 'release', 19.0, 'os_osx', locale)
+ good_url = ('/{locale}/products/download.html?product=firefox-19.0&'
+ 'os=osx&lang={locale}').format(locale=locale)
+ eq_(url, good_url)
Please sign in to comment.
Something went wrong with that request. Please try again.