From 1a8d51522797e6828e4abe248244e28f82ed8383 Mon Sep 17 00:00:00 2001 From: Paul McLanahan Date: Tue, 6 May 2014 14:39:39 -0400 Subject: [PATCH] Fix bug 1006639: Update whatsnew and firstrun views for Fx > 29.0 --- bedrock/firefox/tests/test_base.py | 11 +++++++++++ bedrock/firefox/views.py | 21 ++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/bedrock/firefox/tests/test_base.py b/bedrock/firefox/tests/test_base.py index a4f120d311c..e0912041b31 100644 --- a/bedrock/firefox/tests/test_base.py +++ b/bedrock/firefox/tests/test_base.py @@ -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/') @@ -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/') @@ -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/') @@ -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.""" diff --git a/bedrock/firefox/views.py b/bedrock/firefox/views.py index 6447359649b..651b27a3996 100644 --- a/bedrock/firefox/views.py +++ b/bedrock/firefox/views.py @@ -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' @@ -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(), @@ -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: