Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[fix bug 979217] Make Australis tour available at a secondary URL for link in the Help menu #1749

Merged
merged 1 commit into from

2 participants

@alexgibson
Collaborator
bedrock/firefox/views.py
@@ -410,6 +410,20 @@ def get_template_names(self):
return template
+class TourView(LatestFxView):
+
+ def get(self, request, *args, **kwargs):
+ if not settings.DEV and not request.is_secure():
+ uri = 'https://{host}{path}'.format(
+ host=request.get_host(),
+ path=request.get_full_path(),
+ )
+ return HttpResponsePermanentRedirect(uri)
+ return super(TourView, self).get(request, *args, **kwargs)
+
+ template_name = 'firefox/whatsnew-aurora-29.html'
@pmclanahan Owner

This template name is a bit generic. Is it going to stay specific to aurora 29, or will it change to beta-29 etc.? Should it be something more like "australis-tour.html"?

@pmclanahan Owner

Also class variables like template_name typically go at the beginning of the Class definition, before any methods.

@alexgibson Collaborator

This template name is a bit generic. Is it going to stay specific to aurora 29, or will it change to beta-29 etc.? Should it be something more like "australis-tour.html"?

I agree this is a bit generic atm - for beta we will have two tours, one for /whatsnew and one for /firstrun. I'm not sure which will be available at this new URL when the time comes, but at the next update the template names will certainly be changing to something more specific.

I'm currently working on the next round of updates to the tour design & templates, so I'd like to hold off changing the template name here until then, if that sounds ok?

Will move it to the beginning of the class definition :+1:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@alexgibson
Collaborator

Updated, thanks @pmclanahan

@pmclanahan pmclanahan merged commit f65a6a2 into mozilla:master
@alexgibson alexgibson deleted the alexgibson:bug-979217-make-australis-tour-available-at-secondary-url-for-link-in-help-menu branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 5, 2014
  1. @alexgibson
This page is out of date. Refresh to see the latest.
View
35 bedrock/firefox/tests/test_base.py
@@ -476,6 +476,41 @@ def test_fx_australis_secure_redirect_secure(self, render_mock):
eq_(resp.status_code, 200)
+@patch.object(fx_views.TourView, 'redirect_to', none_mock)
+@patch('bedrock.firefox.views.l10n_utils.render', return_value=HttpResponse())
+class TestTourView(TestCase):
+ def setUp(self):
+ self.view = fx_views.TourView.as_view()
+ self.rf = RequestFactory(HTTP_USER_AGENT='Firefox')
+
+ @override_settings(DEV=False)
+ def test_fx_australis_secure_redirect(self, render_mock):
+ """Should redirect to https"""
+ url = '/en-US/firefox/tour/'
+ req = self.rf.get(url)
+ with patch.object(req, 'is_secure', return_value=False):
+ resp = self.view(req, fx_version='29.0a2')
+ eq_(resp['location'], 'https://testserver' + url)
+
+ @override_settings(DEV=True)
+ def test_fx_australis_secure_redirect_not_dev(self, render_mock):
+ """Should not redirect to https: in DEV mode."""
+ url = '/en-US/firefox/tour/'
+ req = self.rf.get(url)
+ with patch.object(req, 'is_secure', return_value=False):
+ resp = self.view(req, fx_version='29.0a2')
+ eq_(resp.status_code, 200)
+
+ @override_settings(DEV=True)
+ def test_fx_australis_secure_redirect_secure(self, render_mock):
+ """Should not redirect to https: when already secure."""
+ url = '/en-US/firefox/tour/'
+ req = self.rf.get(url)
+ with patch.object(req, 'is_secure', return_value=True):
+ resp = self.view(req, fx_version='29.0a2')
+ eq_(resp.status_code, 200)
+
+
@patch.object(fx_views.FirstrunView, 'redirect_to', none_mock)
@patch('bedrock.firefox.views.l10n_utils.render', return_value=HttpResponse())
class TestFirstRun(TestCase):
View
2  bedrock/firefox/urls.py
@@ -13,6 +13,7 @@
latest_re = r'^firefox(?:/(?P<fx_version>%s))?/%s/$'
firstrun_re = latest_re % (version_re, 'firstrun')
whatsnew_re = latest_re % (version_re, 'whatsnew')
+tour_re = latest_re % (version_re, 'tour')
product_re = '(?P<product>firefox|mobile)'
channel_re = '(?P<channel>beta|aurora|organizations)'
releasenotes_re = latest_re % (version_re, 'releasenotes')
@@ -64,6 +65,7 @@
url('^dnt/$', views.dnt, name='firefox.dnt'),
url(firstrun_re, views.FirstrunView.as_view(), name='firefox.firstrun'),
url(whatsnew_re, views.WhatsnewView.as_view(), name='firefox.whatsnew'),
+ url(tour_re, views.TourView.as_view(), name='firefox.tour'),
url(r'^firefox/partners/$', views.firefox_partners,
name='firefox.partners.index'),
View
13 bedrock/firefox/views.py
@@ -410,6 +410,19 @@ def get_template_names(self):
return template
+class TourView(LatestFxView):
+ template_name = 'firefox/whatsnew-aurora-29.html'
+
+ def get(self, request, *args, **kwargs):
+ if not settings.DEV and not request.is_secure():
+ uri = 'https://{host}{path}'.format(
+ host=request.get_host(),
+ path=request.get_full_path(),
+ )
+ return HttpResponsePermanentRedirect(uri)
+ return super(TourView, self).get(request, *args, **kwargs)
+
+
def fix_fx_version(fx_version):
if len(fx_version.split('.')) == 2:
return fx_version + '.0'
View
3  etc/httpd/global.conf
@@ -682,3 +682,6 @@ RewriteRule ^/(\w{2,3}(?:-\w{2})?/)?firefox/aurora/up-to-date(/?)$ /b/$1firefox/
# bug 971244
RewriteRule ^/firefox/its-a-trap.html$ http://www.itisatrap.org/firefox/its-a-trap.html [L]
RewriteRule ^/firefox/its-an-attack.html$ http://www.itisatrap.org/firefox/its-an-attack.html [L]
+
+# bug 979217
+RewriteRule ^/(\w{2,3}(?:-\w{2})?/)?firefox(/(?:\d+\.\d+\.?(?:\d+)?\.?(?:\d+)?(?:[a|b]?)(?:\d*)(?:pre)?(?:\d)?))?/tour(/?)$ /b/$1firefox$2/tour$3 [PT]
Something went wrong with that request. Please try again.