diff --git a/docs/topics/api/misc.rst b/docs/topics/api/misc.rst index 3a7199bce0..5dcd05874c 100644 --- a/docs/topics/api/misc.rst +++ b/docs/topics/api/misc.rst @@ -20,7 +20,8 @@ Returns the list of categories:: "previous": null, "total_count": 1}, "objects": [{"id": 1, "name": "Webapp", - "resource_uri": "/api/apps/category/1/"}] + "resource_uri": "/api/apps/category/1/", + "slug": "webapp"}] } Use the `id` of the category in your app updating. diff --git a/mkt/api/resources.py b/mkt/api/resources.py index bd9220aa38..19284effbd 100644 --- a/mkt/api/resources.py +++ b/mkt/api/resources.py @@ -271,7 +271,7 @@ class CategoryResource(MarketplaceResource): weight__gte=0) list_allowed_methods = ['get'] allowed_methods = ['get'] - fields = ['name', 'id'] + fields = ['name', 'id', 'slug'] always_return_data = True resource_name = 'category' serializer = Serializer(formats=['json']) diff --git a/mkt/api/tests/test_handlers.py b/mkt/api/tests/test_handlers.py index a89b3ba6d6..85b56bc7a7 100644 --- a/mkt/api/tests/test_handlers.py +++ b/mkt/api/tests/test_handlers.py @@ -556,7 +556,8 @@ class TestCategoryHandler(BaseOAuth): def setUp(self): super(TestCategoryHandler, self).setUp() self.cat = Category.objects.create(name='Webapp', - type=amo.ADDON_WEBAPP) + type=amo.ADDON_WEBAPP, + slug='thewebapp') self.cat.name = {'fr': 'Le Webapp'} self.cat.save() self.other = Category.objects.create(name='other', @@ -583,6 +584,7 @@ class TestCategoryHandler(BaseOAuth): data = json.loads(res.content) eq_(data['meta']['total_count'], 1) eq_(data['objects'][0]['name'], 'Webapp') + eq_(data['objects'][0]['slug'], 'thewebapp') def test_get_category(self): res = self.client.get(self.get_url)