Skip to content

Commit

Permalink
Merge pull request #1977 from pmclanahan/update-fx-tour-version-1006639
Browse files Browse the repository at this point in the history
Fix bug 1006639: Update whatsnew and firstrun views for Fx > 29.0
  • Loading branch information
alexgibson committed May 6, 2014
2 parents 7de4f1c + 1a8d515 commit cc74b3a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
11 changes: 11 additions & 0 deletions bedrock/firefox/tests/test_base.py
Expand Up @@ -415,6 +415,7 @@ def setUp(self):
self.view = fx_views.WhatsnewView.as_view()
self.rf = RequestFactory(HTTP_USER_AGENT='Firefox')

@override_settings(DEV=True)
def test_can_post(self, render_mock):
"""Home page must accept post for newsletter signup."""
req = self.rf.post('/en-US/firefox/whatsnew/')
Expand All @@ -423,6 +424,7 @@ def test_can_post(self, render_mock):
render_mock.assert_called_once_with(req, ['firefox/whatsnew.html'], ANY)

@patch.object(fx_views.WhatsnewView, 'fxos_locales', ['de'])
@override_settings(DEV=True)
def test_fxos_locales(self, render_mock):
"""Should use a different template for fxos locales."""
req = self.rf.get('/de/firefox/whatsnew/')
Expand All @@ -433,6 +435,7 @@ def test_fxos_locales(self, render_mock):
ok_('locales_with_video' not in ctx)
eq_(template, ['firefox/whatsnew-fxos.html'])

@override_settings(DEV=True)
def test_fx_nightly_29(self, render_mock):
"""Should use special nightly template for 29.0a1."""
req = self.rf.get('/en-US/firefox/whatsnew/')
Expand All @@ -448,6 +451,14 @@ def test_fx_australis_29(self, render_mock):
template = render_mock.call_args[0][1]
eq_(template, ['firefox/australis/whatsnew-tour.html'])

@override_settings(DEV=True)
def test_fx_australis_29_0_1(self, render_mock):
"""Should use australis template for 29.0.1"""
req = self.rf.get('/en-US/firefox/whatsnew/')
self.view(req, fx_version='29.0.1')
template = render_mock.call_args[0][1]
eq_(template, ['firefox/australis/whatsnew-tour.html'])

@override_settings(DEV=False)
def test_fx_australis_secure_redirect(self, render_mock):
"""Should redirect to https: for 29.0."""
Expand Down
21 changes: 8 additions & 13 deletions bedrock/firefox/views.py
Expand Up @@ -358,12 +358,11 @@ def get(self, request, *args, **kwargs):
return super(FirstrunView, self).get(request, *args, **kwargs)

def get_template_names(self):
version = self.kwargs.get('fx_version')
locale = l10n_utils.get_locale(self.request)
fc_ctx = funnelcake_param(self.request)
f = fc_ctx.get('funnelcake_id', 0)

if version == '29.0' and locale == 'en-US' and f == '30':
if f == '30' and locale == 'en-US':
template = 'firefox/australis/firstrun-no-tour.html'
else:
template = 'firefox/australis/firstrun-tour.html'
Expand All @@ -389,8 +388,7 @@ class WhatsnewView(LatestFxView):
}

def get(self, request, *args, **kwargs):
version = kwargs.get('fx_version')
if version == '29.0' and not settings.DEV and not request.is_secure():
if not settings.DEV and not request.is_secure():
uri = 'https://{host}{path}'.format(
host=request.get_host(),
path=request.get_full_path(),
Expand All @@ -409,21 +407,18 @@ def get_context_data(self, **kwargs):
return ctx

def get_template_names(self):
version = self.kwargs.get('fx_version')
version = self.kwargs.get('fx_version') or ''
locale = l10n_utils.get_locale(self.request)
fc_ctx = funnelcake_param(self.request)
f = fc_ctx.get('funnelcake_id', 0)

if version == '29.0' and locale == 'en-US':
if f == '30':
template = 'firefox/australis/whatsnew-no-tour.html'
else:
template = 'firefox/australis/whatsnew-tour.html'
elif version == '29.0':
# non en-US locales always get the tour
template = 'firefox/australis/whatsnew-tour.html'
if f == '30' and locale == 'en-US':
template = 'firefox/australis/whatsnew-no-tour.html'
elif version == '29.0a1':
template = 'firefox/whatsnew-nightly-29.html'
elif version.startswith('29.'):
# non en-US locales always get the tour
template = 'firefox/australis/whatsnew-tour.html'
elif locale in self.fxos_locales:
template = 'firefox/whatsnew-fxos.html'
else:
Expand Down

0 comments on commit cc74b3a

Please sign in to comment.