Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion kitsune/bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -631,5 +637,5 @@
'kpi/js/kpi.browserify.js',
),
'output_filename': 'build/kpi.dashboard-min.js'
}
},
}
9 changes: 9 additions & 0 deletions kitsune/products/tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<product slug>/<topic slug> renders articles."""
# Create a topic and product.
Expand Down
14 changes: 7 additions & 7 deletions kitsune/products/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
})


Expand All @@ -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,
Expand All @@ -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}
})
11 changes: 8 additions & 3 deletions kitsune/sumo/jinja2/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@
{% if not hide_locale_switcher %}
<li><a href="{{ locale_picker_url }}" class="locale-picker">{{ settings.LANGUAGES_DICT[request.LANGUAGE_CODE.lower()] }}</a></li>
{% endif %}
{% if show_fx_download and not user.is_authenticated() %}
<a href="https://www.mozilla.org/firefox/new/?scene=2&utm_source=support.mozilla.org&utm_medium=referral&utm_campaign=non-fx-button#download-fx"
class="firefox-download-button" data-ga-click="_trackEvent | Download Button | Firefox button on Thunderbird article">
{% if not (hide_fx_download or user.is_authenticated()) %}
<a href="https://www.mozilla.org/firefox/new/?utm_source=support.mozilla.org&utm_medium=referral&utm_campaign=non-fx-button"
class="firefox-download-button hidden" data-ga-click="_trackEvent | Download Button | Firefox for Desktop">
<strong class="download-title">{{ _('Download Firefox') }}</strong>
</a>
{% endif %}
Expand Down Expand Up @@ -244,6 +244,11 @@
{% javascript script %}
{% endfor %}

{# Show firefox download button to unauthenticated users only #}
{% if not user.is_authenticated() %}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be the same logic from line 141 I think

{% if not (hide_fx_download or user.is_authenticated()) %}

{% javascript 'common.fx.download' %}
{% endif %}

{# Temporary Pontoon testing - bug 812176 #}
{% if settings.STAGE %}
<script src="https://pontoon.mozilla.org/pontoon.js"></script>
Expand Down
13 changes: 13 additions & 0 deletions kitsune/sumo/static/sumo/js/show-fx-download.js
Original file line number Diff line number Diff line change
@@ -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');
}

})();
5 changes: 5 additions & 0 deletions kitsune/sumo/static/sumo/less/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,11 @@ input[type=button],
text-transform: capitalize;
}
}

.hidden {
display: none;
}

}

.html-rtl {
Expand Down