Add number of users and downloads to the add-on search/detail API
This commit is contained in:
Родитель
854a2ff681
Коммит
32afce5bad
|
@ -72,6 +72,7 @@ This endpoint allows you to fetch a specific add-on by id, slug or guid.
|
|||
:>json int authors[].id: The id for an author.
|
||||
:>json string authors[].name: The name for an author.
|
||||
:>json string authors[].url: The link to the profile page for an author.
|
||||
:>json int average_daily_users: The average number of users for the add-on per day.
|
||||
:>json object compatibility: Object detailing the add-on :ref:`add-on application <addon-detail-application>` and version compatibility.
|
||||
:>json object compatibility[app_name].max: Maximum version of the corresponding app the add-on is compatible with.
|
||||
:>json object compatibility[app_name].min: Minimum version of the corresponding app the add-on is compatible with.
|
||||
|
@ -115,6 +116,7 @@ This endpoint allows you to fetch a specific add-on by id, slug or guid.
|
|||
:>json object theme_data: Object holding `lightweight theme (Persona) <https://developer.mozilla.org/en-US/Add-ons/Themes/Lightweight_themes>`_ data. Only present for themes (Persona).
|
||||
:>json string type: The :ref:`add-on type <addon-detail-type>`.
|
||||
:>json string url: The (absolute) add-on detail URL.
|
||||
:>json int weekly_downloads: The number of downloads for the add-on per week.
|
||||
|
||||
|
||||
.. _addon-detail-status:
|
||||
|
|
|
@ -132,12 +132,12 @@ class AddonSerializer(serializers.ModelSerializer):
|
|||
|
||||
class Meta:
|
||||
model = Addon
|
||||
fields = ('id', 'authors', 'current_version', 'default_locale',
|
||||
'description', 'edit_url', 'guid', 'homepage', 'icon_url',
|
||||
'is_listed', 'name', 'last_updated', 'previews',
|
||||
'public_stats', 'ratings', 'review_url', 'slug', 'status',
|
||||
'summary', 'support_email', 'support_url', 'tags',
|
||||
'theme_data', 'type', 'url')
|
||||
fields = ('id', 'authors', 'average_daily_users', 'current_version',
|
||||
'default_locale', 'description', 'edit_url', 'guid',
|
||||
'homepage', 'icon_url', 'is_listed', 'name', 'last_updated',
|
||||
'previews', 'public_stats', 'ratings', 'review_url', 'slug',
|
||||
'status', 'summary', 'support_email', 'support_url', 'tags',
|
||||
'theme_data', 'type', 'url', 'weekly_downloads')
|
||||
|
||||
def to_representation(self, obj):
|
||||
data = super(AddonSerializer, self).to_representation(obj)
|
||||
|
|
|
@ -22,6 +22,7 @@ class AddonSerializerOutputTestMixin(object):
|
|||
|
||||
def test_basic(self):
|
||||
self.addon = addon_factory(
|
||||
average_daily_users=4242,
|
||||
average_rating=4.21,
|
||||
description=u'My Addôn description',
|
||||
file_kw={
|
||||
|
@ -40,6 +41,7 @@ class AddonSerializerOutputTestMixin(object):
|
|||
support_url=u'https://support.example.org/support/my-addon/',
|
||||
tags=['some_tag', 'some_other_tag'],
|
||||
total_reviews=666,
|
||||
weekly_downloads=2147483647,
|
||||
)
|
||||
AddonUser.objects.create(user=user_factory(username='hidden_author'),
|
||||
addon=self.addon, listed=False)
|
||||
|
@ -62,6 +64,8 @@ class AddonSerializerOutputTestMixin(object):
|
|||
|
||||
assert result['id'] == self.addon.pk
|
||||
|
||||
assert result['average_daily_users'] == self.addon.average_daily_users
|
||||
|
||||
assert result['current_version']
|
||||
assert result['current_version']['id'] == version.pk
|
||||
assert result['current_version']['compatibility'] == {
|
||||
|
@ -145,6 +149,8 @@ class AddonSerializerOutputTestMixin(object):
|
|||
assert set(result['tags']) == set(['some_tag', 'some_other_tag'])
|
||||
assert result['type'] == 'extension'
|
||||
assert result['url'] == absolutify(self.addon.get_url_path())
|
||||
assert result['weekly_downloads'] == self.addon.weekly_downloads
|
||||
|
||||
return result
|
||||
|
||||
def test_icon_url_without_icon_type_set(self):
|
||||
|
|
Загрузка…
Ссылка в новой задаче