add theme as alias for persona in search API (bug 867841)
This commit is contained in:
Родитель
9b926b5b31
Коммит
2916ef22e9
|
@ -1,5 +1,5 @@
|
|||
from datetime import datetime
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
from tower import ugettext_lazy as _
|
||||
|
||||
|
@ -263,12 +263,9 @@ ADDON_SEARCH_SLUGS = {
|
|||
|
||||
# Marketplace search API addon types.
|
||||
MKT_ADDON_TYPES_API = {
|
||||
ADDON_PERSONA: 'persona',
|
||||
ADDON_WEBAPP: 'app',
|
||||
'theme': ADDON_PERSONA,
|
||||
'app': ADDON_WEBAPP,
|
||||
}
|
||||
MKT_ADDON_TYPES_API_LOOKUP = dict(
|
||||
(v, k) for k, v in MKT_ADDON_TYPES_API.items())
|
||||
|
||||
|
||||
ADDON_FREE = 0
|
||||
ADDON_PREMIUM = 1
|
||||
|
|
|
@ -24,7 +24,7 @@ Search
|
|||
premium or has in-app purchasing. Any of 'free', 'free-inapp',
|
||||
'premium', 'premium-inapp', or 'other'.
|
||||
:param optional addon_type: Filters by type of add-on. One of 'app' or
|
||||
'persona'.
|
||||
'theme'.
|
||||
:param optional app_type: Filters by type of web app. One of 'hosted' or
|
||||
'packaged'.
|
||||
:param optional sort: The field to sort by. One of 'downloads', 'rating',
|
||||
|
|
|
@ -9,7 +9,7 @@ import amo
|
|||
from mkt.api.forms import SluggableModelChoiceField
|
||||
|
||||
|
||||
ADDON_CHOICES = [(v, v) for k, v in amo.MKT_ADDON_TYPES_API.items()]
|
||||
ADDON_CHOICES = [(k, k) for k in amo.MKT_ADDON_TYPES_API.keys()]
|
||||
|
||||
# We set 'any' here since we need to default this field
|
||||
# to PUBLIC if not specified for consumer pages.
|
||||
|
@ -177,8 +177,8 @@ class ApiSearchForm(forms.Form):
|
|||
return self.cleaned_data['cat'].pk
|
||||
|
||||
def clean_type(self):
|
||||
return amo.MKT_ADDON_TYPES_API_LOOKUP.get(self.cleaned_data['type'],
|
||||
amo.ADDON_WEBAPP)
|
||||
return amo.MKT_ADDON_TYPES_API.get(self.cleaned_data['type'],
|
||||
amo.ADDON_WEBAPP)
|
||||
|
||||
def clean_status(self):
|
||||
status = self.cleaned_data['status']
|
||||
|
|
|
@ -185,7 +185,7 @@ class TestApi(BaseOAuth, ESTestCase):
|
|||
error = json.loads(res.content)['error_message']
|
||||
eq_(error.keys(), ['type'])
|
||||
|
||||
res = self.client.get(self.url + ({'type': 'persona'},))
|
||||
res = self.client.get(self.url + ({'type': 'theme'},))
|
||||
eq_(res.status_code, 200)
|
||||
objs = json.loads(res.content)['objects']
|
||||
eq_(len(objs), 0)
|
||||
|
@ -247,7 +247,7 @@ class TestApiReviewer(BaseOAuth, ESTestCase):
|
|||
obj = json.loads(res.content)['objects'][0]
|
||||
eq_(obj['slug'], self.webapp.app_slug)
|
||||
|
||||
res = self.client.get(self.url + ({'type': 'persona'},))
|
||||
res = self.client.get(self.url + ({'type': 'theme'},))
|
||||
eq_(res.status_code, 200)
|
||||
objs = json.loads(res.content)['objects']
|
||||
eq_(len(objs), 0)
|
||||
|
|
|
@ -59,7 +59,7 @@ class TestSearchFilters(BaseOAuth):
|
|||
# happens in the view, not the _filter_search call.
|
||||
self._addon_type_check({})
|
||||
self._addon_type_check({'type': 'app'})
|
||||
self._addon_type_check({'type': 'persona'})
|
||||
self._addon_type_check({'type': 'theme'})
|
||||
# Test a bad value.
|
||||
qs = self._filter(self.req, {'type': 'vindaloo'})
|
||||
ok_(u'Select a valid choice' in qs['type'][0])
|
||||
|
|
Загрузка…
Ссылка в новой задаче