Prioritize mobile's UA over firefox. Bug 588291
This commit is contained in:
Родитель
7088dfd0d6
Коммит
c3e6292014
|
@ -222,6 +222,8 @@ class MOZILLA:
|
|||
ADDON_LPAPP, ADDON_PLUGIN]
|
||||
guid = '{86c18b42-e466-45a9-ae7a-9b95ba6f5640}'
|
||||
|
||||
# UAs will attempt to match in this order
|
||||
APP_DETECT = (MOBILE, FIREFOX, THUNDERBIRD, SEAMONKEY, SUNBIRD)
|
||||
APP_USAGE = _apps = (FIREFOX, THUNDERBIRD, MOBILE, SEAMONKEY, SUNBIRD)
|
||||
APPS = dict((app.short, app) for app in _apps)
|
||||
APP_IDS = dict((app.id, app) for app in _apps)
|
||||
|
|
|
@ -72,6 +72,9 @@ class MiddlewareTest(test.TestCase):
|
|||
check('/en-US/', '/en-US/firefox/', 'Firefox')
|
||||
check('/de/', '/de/mobile/', 'Fennec')
|
||||
|
||||
# Mobile gets priority because it has both strings in its UA...
|
||||
check('/de/', '/de/mobile/', 'Firefox Fennec')
|
||||
|
||||
def test_get_lang(self):
|
||||
def check(url, expected):
|
||||
response = self.process(url)
|
||||
|
|
|
@ -100,14 +100,13 @@ class Prefixer(object):
|
|||
Return a valid application string using the User Agent to guess. Falls
|
||||
back to settings.DEFAULT_APP.
|
||||
"""
|
||||
app = settings.DEFAULT_APP
|
||||
ua = self.request.META.get('HTTP_USER_AGENT')
|
||||
if ua:
|
||||
for i in amo.APPS.values():
|
||||
if i.user_agent_string in ua:
|
||||
app = i.short
|
||||
for app in amo.APP_DETECT:
|
||||
if app.user_agent_string in ua:
|
||||
return app.short
|
||||
|
||||
return app
|
||||
return settings.DEFAULT_APP
|
||||
|
||||
def get_language(self):
|
||||
"""
|
||||
|
|
Загрузка…
Ссылка в новой задаче