include price_locale.
return None for price on free apps
This commit is contained in:
Родитель
927b66b7d1
Коммит
b752beaf42
|
@ -184,6 +184,7 @@ App resource
|
|||
}
|
||||
],
|
||||
"price": null,
|
||||
"price_locale": null,
|
||||
"previews": [
|
||||
{
|
||||
"filetype": "image/png",
|
||||
|
|
|
@ -232,8 +232,7 @@ class AppResource(CORSResource, MarketplaceModelResource):
|
|||
upsell_bundle = Bundle(obj=obj.upsell.premium,
|
||||
request=bundle.request)
|
||||
bundle.data['upsell'] = self.full_dehydrate(upsell_bundle).data
|
||||
|
||||
if bundle.data.get('price') == 'Free':
|
||||
if not obj.has_price():
|
||||
bundle.data['price'] = None
|
||||
return bundle
|
||||
|
||||
|
|
|
@ -463,6 +463,7 @@ class TestAppCreateHandler(CreateHandler, AMOPaths):
|
|||
eq_(data['manifest_url'], app.manifest_url)
|
||||
eq_(data['premium_type'], 'free')
|
||||
eq_(data['price'], None)
|
||||
eq_(data['price_locale'], None)
|
||||
eq_(data['public_stats'], False)
|
||||
eq_(data['support_email'], u'a@a.com')
|
||||
eq_(data['ratings'], {'count': 0, 'average': 0.0})
|
||||
|
@ -693,12 +694,17 @@ class TestAppDetail(BaseOAuth, AMOPaths):
|
|||
fixtures = fixture('user_2519', 'webapp_337141')
|
||||
|
||||
def test_price(self):
|
||||
self.get_url = ('api_dispatch_detail',
|
||||
{'resource_name': 'app', 'pk': 337141})
|
||||
self.get_url = get_url('app', pk=337141)
|
||||
res = self.client.get(self.get_url)
|
||||
data = json.loads(res.content)
|
||||
eq_(data['price'], None)
|
||||
|
||||
def test_price_other_region(self):
|
||||
self.get_url = get_url('app', pk=337141)
|
||||
res = self.client.get(self.get_url, {'lang': 'fr'})
|
||||
data = json.loads(res.content)
|
||||
eq_(data['price'], None)
|
||||
|
||||
|
||||
class TestCategoryHandler(BaseOAuth):
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@ def app_to_dict(app, user=None):
|
|||
'premium_type': amo.ADDON_PREMIUM_API[app.premium_type],
|
||||
'public_stats': app.public_stats,
|
||||
'price': app.get_price(),
|
||||
'price_locale': (app.premium.get_price_locale()
|
||||
if app.premium else None),
|
||||
'ratings': {'average': app.average_rating,
|
||||
'count': app.total_reviews},
|
||||
'slug': app.app_slug,
|
||||
|
|
Загрузка…
Ссылка в новой задаче