diff --git a/docs/topics/api/submission.rst b/docs/topics/api/submission.rst index 4e2d04a41f..5d13ca9212 100644 --- a/docs/topics/api/submission.rst +++ b/docs/topics/api/submission.rst @@ -184,6 +184,7 @@ App resource } ], "price": null, + "price_locale": null, "previews": [ { "filetype": "image/png", diff --git a/mkt/api/resources.py b/mkt/api/resources.py index a86dd1fe93..98c886ffdf 100644 --- a/mkt/api/resources.py +++ b/mkt/api/resources.py @@ -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 diff --git a/mkt/api/tests/test_handlers.py b/mkt/api/tests/test_handlers.py index 9754ac6a67..e6acfe7ee1 100644 --- a/mkt/api/tests/test_handlers.py +++ b/mkt/api/tests/test_handlers.py @@ -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): diff --git a/mkt/webapps/utils.py b/mkt/webapps/utils.py index 8f2af7243b..a450fadeca 100644 --- a/mkt/webapps/utils.py +++ b/mkt/webapps/utils.py @@ -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,