diff --git a/kitsune/bundles.py b/kitsune/bundles.py index 225757c6240..17300941e27 100644 --- a/kitsune/bundles.py +++ b/kitsune/bundles.py @@ -300,6 +300,12 @@ ), 'output_filename': 'build/common-min.js' }, + 'common.fx.download': { + 'source_filenames': ( + 'sumo/js/show-fx-download.js', + ), + 'output_filename': 'build/show-fx-download.js' + }, 'community': { 'source_filenames': ( 'jquery/jquery.min.js', @@ -631,5 +637,5 @@ 'kpi/js/kpi.browserify.js', ), 'output_filename': 'build/kpi.dashboard-min.js' - } + }, } diff --git a/kitsune/products/tests/test_templates.py b/kitsune/products/tests/test_templates.py index c1872022d53..ba46a4601cb 100644 --- a/kitsune/products/tests/test_templates.py +++ b/kitsune/products/tests/test_templates.py @@ -53,6 +53,15 @@ def test_product_landing(self): eq_(11, len(doc('#help-topics li'))) eq_(p.slug, doc('#support-search input[name=product]').attr['value']) + def test_firefox_product_landing(self): + """Verify that there are no firefox button at header in the firefox landing page""" + p = ProductFactory(slug="firefox") + url = reverse('products.product', args=[p.slug]) + r = self.client.get(url, follow=True) + eq_(200, r.status_code) + doc = pq(r.content) + eq_(False, doc(".firefox-download-button").length) + def test_document_listing(self): """Verify /products// renders articles.""" # Create a topic and product. diff --git a/kitsune/products/views.py b/kitsune/products/views.py index ae626dfa4a2..a7ddb09095d 100644 --- a/kitsune/products/views.py +++ b/kitsune/products/views.py @@ -44,12 +44,16 @@ def product_landing(request, template, slug): else: latest_version = 0 + # Don't show firefox download button at header at firefox product page + hide_fx_download = product.slug == 'firefox' + return render(request, template, { 'product': product, 'products': Product.objects.filter(visible=True), 'topics': topics_for(product=product, parent=None), 'search_params': {'product': slug}, - 'latest_version': latest_version + 'latest_version': latest_version, + 'hide_fx_download': hide_fx_download }) @@ -74,10 +78,6 @@ def document_listing(request, template, product_slug, topic_slug, documents, fallback_documents = documents_for(**doc_kw) - user_agent = request.META.get('HTTP_USER_AGENT', '') - browser = get_browser(user_agent) - show_fx_download = (product.slug == 'thunderbird' and browser != 'Firefox') - return render(request, template, { 'product': product, 'topic': topic, @@ -86,5 +86,5 @@ def document_listing(request, template, product_slug, topic_slug, 'subtopics': topics_for(product=product, parent=topic), 'documents': documents, 'fallback_documents': fallback_documents, - 'search_params': {'product': product_slug}, - 'show_fx_download': show_fx_download}) + 'search_params': {'product': product_slug} + }) diff --git a/kitsune/sumo/jinja2/base.html b/kitsune/sumo/jinja2/base.html index 25c9f22c1d4..ddb15adbef8 100644 --- a/kitsune/sumo/jinja2/base.html +++ b/kitsune/sumo/jinja2/base.html @@ -138,9 +138,9 @@ {% if not hide_locale_switcher %}
  • {{ settings.LANGUAGES_DICT[request.LANGUAGE_CODE.lower()] }}
  • {% endif %} - {% if show_fx_download and not user.is_authenticated() %} - + {% if not (hide_fx_download or user.is_authenticated()) %} + {% endif %} @@ -244,6 +244,11 @@ {% javascript script %} {% endfor %} +{# Show firefox download button to unauthenticated users only #} +{% if not (hide_fx_download or user.is_authenticated()) %} + {% javascript 'common.fx.download' %} +{% endif %} + {# Temporary Pontoon testing - bug 812176 #} {% if settings.STAGE %} diff --git a/kitsune/sumo/static/sumo/js/show-fx-download.js b/kitsune/sumo/static/sumo/js/show-fx-download.js new file mode 100644 index 00000000000..dfb5761ee8e --- /dev/null +++ b/kitsune/sumo/static/sumo/js/show-fx-download.js @@ -0,0 +1,13 @@ +(function() { + var isFirefox = function () { + var userAgent = navigator.userAgent.toLowerCase(); + return userAgent.includes('firefox'); + }; + + if (!isFirefox()) { + /* remove the hide class from the download button as the browser is not firefox */ + var fxDownloadButton = document.getElementsByClassName('firefox-download-button')[0]; + fxDownloadButton.classList.remove('hidden'); + } + +})(); diff --git a/kitsune/sumo/static/sumo/less/main.less b/kitsune/sumo/static/sumo/less/main.less index 136868eeafa..ae813297b36 100644 --- a/kitsune/sumo/static/sumo/less/main.less +++ b/kitsune/sumo/static/sumo/less/main.less @@ -1252,6 +1252,11 @@ input[type=button], text-transform: capitalize; } } + + .hidden { + display: none; + } + } .html-rtl {