Skip to content

Commit

Permalink
Make /whatsnew urls use the new Geo redirector view class (Fixes mozi…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson committed Sep 18, 2019
1 parent 8ff3809 commit dc49207
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion bedrock/firefox/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
latest_re = r'^firefox(?:/(?P<version>%s))?/%s/$'
firstrun_re = latest_re % (version_re, 'firstrun')
whatsnew_re = latest_re % (version_re, 'whatsnew')
whatsnew_re_all = latest_re % (version_re, 'whatsnew/all')
tracking_protection_re = latest_re % (version_re, 'tracking-protection/start')
content_blocking_re = latest_re % (version_re, 'content-blocking/start')
platform_re = '(?P<platform>android|ios)'
Expand Down Expand Up @@ -71,7 +72,8 @@
url(r'^firefox/installer-help/$', views.installer_help,
name='firefox.installer-help'),
url(firstrun_re, views.FirstrunView.as_view(), name='firefox.firstrun'),
url(whatsnew_re, views.WhatsnewView.as_view(), name='firefox.whatsnew'),
url(whatsnew_re, views.WhatsNewRedirectorView.as_view(), name='firefox.whatsnew'),
url(whatsnew_re_all, views.WhatsnewView.as_view(), name='firefox.whatsnew.all'),
url(tracking_protection_re, views.TrackingProtectionTourView.as_view(),
name='firefox.tracking-protection-tour.start'),
url(content_blocking_re, views.ContentBlockingTourView.as_view(),
Expand Down
12 changes: 12 additions & 0 deletions bedrock/firefox/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from bedrock.newsletter.forms import NewsletterFooterForm
from bedrock.releasenotes import version_re
from bedrock.wordpress.views import BlogPostsView
from bedrock.base.views import GeoRedirectView

UA_REGEXP = re.compile(r"Firefox/(%s)" % version_re)

Expand Down Expand Up @@ -535,6 +536,17 @@ def get_template_names(self):
return [template]


class WhatsNewRedirectorView(GeoRedirectView):
geo_urls = {}
default_url = 'firefox.whatsnew.all'

def get_redirect_url(self, *args, **kwargs):
if 'version' in kwargs and kwargs['version'] is None:
del kwargs['version']

return super().get_redirect_url(*args, **kwargs)


class WhatsnewView(l10n_utils.LangFilesMixin, TemplateView):
def get_context_data(self, **kwargs):
ctx = super(WhatsnewView, self).get_context_data(**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion tests/pages/firefox/whatsnew.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class FirefoxWhatsNewPage(FirefoxBasePage):

URL_TEMPLATE = '/{locale}/firefox/whatsnew/'
URL_TEMPLATE = '/{locale}/firefox/whatsnew/all/'

_qr_code_locator = (By.CSS_SELECTOR, '.qr-code img')

Expand Down

0 comments on commit dc49207

Please sign in to comment.