Ignoring non ints for addon_type in list api.
This commit is contained in:
Родитель
6bd85c43d9
Коммит
6b4183aae0
|
@ -26,7 +26,7 @@ class No500ErrorsTest(TestCase):
|
||||||
"""
|
"""
|
||||||
A series of unfortunate urls that have caused 500 errors in the past.
|
A series of unfortunate urls that have caused 500 errors in the past.
|
||||||
"""
|
"""
|
||||||
def test_bad_type(self):
|
def test_search_bad_type(self):
|
||||||
"""
|
"""
|
||||||
For search/:term/:addon_type <-- addon_type should be an integer.
|
For search/:term/:addon_type <-- addon_type should be an integer.
|
||||||
"""
|
"""
|
||||||
|
@ -35,6 +35,13 @@ class No500ErrorsTest(TestCase):
|
||||||
# is good. We just don't want 500 errors.
|
# is good. We just don't want 500 errors.
|
||||||
assert response.status_code != 500, "We recieved a 500 error, wtf?"
|
assert response.status_code != 500, "We recieved a 500 error, wtf?"
|
||||||
|
|
||||||
|
def test_list_bad_type(self):
|
||||||
|
"""
|
||||||
|
For list/new/:addon_type <-- addon_type should be an integer.
|
||||||
|
"""
|
||||||
|
response = make_call('/list/new/extension')
|
||||||
|
assert response.status_code != 500, "We recieved a 500 error, wtf?"
|
||||||
|
|
||||||
def test_utf_redirect(self):
|
def test_utf_redirect(self):
|
||||||
"""Test that urls with unicode redirect propperly."""
|
"""Test that urls with unicode redirect propperly."""
|
||||||
response = make_call(u'search/ツールバー', version=1.5)
|
response = make_call(u'search/ツールバー', version=1.5)
|
||||||
|
|
|
@ -184,10 +184,15 @@ class ListView(APIView):
|
||||||
else:
|
else:
|
||||||
qs = Addon.objects.featured(self.request.APP)
|
qs = Addon.objects.featured(self.request.APP)
|
||||||
|
|
||||||
if addon_type.lower() != 'all':
|
if addon_type.upper() != 'ALL':
|
||||||
addon_type = int(addon_type)
|
try:
|
||||||
if addon_type:
|
addon_type = int(addon_type)
|
||||||
qs = qs.filter(type=addon_type)
|
if addon_type:
|
||||||
|
qs = qs.filter(type=addon_type)
|
||||||
|
|
||||||
|
except ValueError:
|
||||||
|
# `addon_type` is ALL or a type id. Otherwise we ignore it.
|
||||||
|
pass
|
||||||
|
|
||||||
if platform.lower() != 'all':
|
if platform.lower() != 'all':
|
||||||
qs = (qs.distinct() &
|
qs = (qs.distinct() &
|
||||||
|
|
Загрузка…
Ссылка в новой задаче