Remove unnecessary file properties from reviewers API responses (#14105)
This commit is contained in:
Родитель
c642718cb5
Коммит
fed8ca24a3
|
@ -165,7 +165,8 @@ This endpoint allows you to browse through the contents of an Add-on version.
|
||||||
:>json string validation_url: The absolute url to the addons-linter validation report, rendered as HTML.
|
:>json string validation_url: The absolute url to the addons-linter validation report, rendered as HTML.
|
||||||
:>json boolean has_been_validated: ``True`` if the version has been validated through addons-linter.
|
:>json boolean has_been_validated: ``True`` if the version has been validated through addons-linter.
|
||||||
:>json object addon: A simplified :ref:`add-on <addon-detail-object>` object that contains only a few properties: ``id``, ``name``, ``icon_url`` and ``slug``.
|
:>json object addon: A simplified :ref:`add-on <addon-detail-object>` object that contains only a few properties: ``id``, ``name``, ``icon_url`` and ``slug``.
|
||||||
:>json object file: The file attached to this version. See :ref:`version detail -> files[] <version-detail-object>` for more details.
|
:>json object file: The requested file.
|
||||||
|
:>json int file.id: The id of the submitted file (i.e., the xpi file).
|
||||||
:>json string file.content: Raw content of the requested file.
|
:>json string file.content: Raw content of the requested file.
|
||||||
:>json string file.selected_file: The selected file, either from the ``file`` parameter or the default (manifest.json, install.rdf or package.json for Add-ons as well as the XML file for search engines).
|
:>json string file.selected_file: The selected file, either from the ``file`` parameter or the default (manifest.json, install.rdf or package.json for Add-ons as well as the XML file for search engines).
|
||||||
:>json string|null file.download_url: The download url of the selected file or ``null`` in case of a directory.
|
:>json string|null file.download_url: The download url of the selected file or ``null`` in case of a directory.
|
||||||
|
|
|
@ -49,7 +49,7 @@ class AddonReviewerFlagsSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
# NOTE: Because of caching, this serializer cannot be reused and must be
|
# NOTE: Because of caching, this serializer cannot be reused and must be
|
||||||
# created for each file. It cannot be used with DRF's many=True option.
|
# created for each file. It cannot be used with DRF's many=True option.
|
||||||
class FileEntriesSerializer(FileSerializer):
|
class FileEntriesSerializer(serializers.ModelSerializer):
|
||||||
content = serializers.SerializerMethodField()
|
content = serializers.SerializerMethodField()
|
||||||
uses_unknown_minified_code = serializers.SerializerMethodField()
|
uses_unknown_minified_code = serializers.SerializerMethodField()
|
||||||
download_url = serializers.SerializerMethodField()
|
download_url = serializers.SerializerMethodField()
|
||||||
|
@ -62,11 +62,10 @@ class FileEntriesSerializer(FileSerializer):
|
||||||
filename = serializers.SerializerMethodField()
|
filename = serializers.SerializerMethodField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
fields = FileSerializer.Meta.fields + (
|
fields = ('id', 'content', 'entries', 'selected_file', 'download_url',
|
||||||
'content', 'entries', 'selected_file', 'download_url',
|
'uses_unknown_minified_code', 'mimetype', 'sha256', 'size',
|
||||||
'uses_unknown_minified_code', 'mimetype', 'sha256', 'size',
|
'mime_category', 'filename'
|
||||||
'mime_category', 'filename'
|
)
|
||||||
)
|
|
||||||
model = File
|
model = File
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
|
@ -350,11 +349,10 @@ class FileEntriesDiffSerializer(FileEntriesSerializer):
|
||||||
base_file = serializers.SerializerMethodField()
|
base_file = serializers.SerializerMethodField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
fields = FileSerializer.Meta.fields + (
|
fields = ('id', 'diff', 'entries', 'selected_file', 'download_url',
|
||||||
'diff', 'entries', 'selected_file', 'download_url',
|
'uses_unknown_minified_code', 'base_file',
|
||||||
'uses_unknown_minified_code', 'base_file',
|
'sha256', 'size', 'mimetype', 'mime_category', 'filename'
|
||||||
'sha256', 'size', 'mimetype', 'mime_category', 'filename'
|
)
|
||||||
)
|
|
||||||
model = File
|
model = File
|
||||||
|
|
||||||
def get_diff(self, obj):
|
def get_diff(self, obj):
|
||||||
|
|
|
@ -60,15 +60,6 @@ class TestFileEntriesSerializer(TestCase):
|
||||||
data = self.serialize(file)
|
data = self.serialize(file)
|
||||||
|
|
||||||
assert data['id'] == file.pk
|
assert data['id'] == file.pk
|
||||||
assert data['status'] == 'public'
|
|
||||||
assert data['hash'] == ''
|
|
||||||
assert data['is_webextension'] is True
|
|
||||||
assert data['created'] == (
|
|
||||||
file.created.replace(microsecond=0).isoformat() + 'Z')
|
|
||||||
assert data['url'] == (
|
|
||||||
'http://testserver/firefox/downloads/file/{}'
|
|
||||||
'/notify-link-clicks-i18n.xpi?src=').format(file.pk)
|
|
||||||
|
|
||||||
assert data['selected_file'] == 'manifest.json'
|
assert data['selected_file'] == 'manifest.json'
|
||||||
assert data['download_url'] == absolutify(reverse(
|
assert data['download_url'] == absolutify(reverse(
|
||||||
'reviewers.download_git_file',
|
'reviewers.download_git_file',
|
||||||
|
@ -110,8 +101,6 @@ class TestFileEntriesSerializer(TestCase):
|
||||||
|
|
||||||
assert '"manifest_version": 2' in data['content']
|
assert '"manifest_version": 2' in data['content']
|
||||||
assert 'id": "notify-link-clicks-i18n@notzilla.org' in data['content']
|
assert 'id": "notify-link-clicks-i18n@notzilla.org' in data['content']
|
||||||
assert data['platform'] == 'all'
|
|
||||||
assert data['is_mozilla_signed_extension'] is False
|
|
||||||
|
|
||||||
def test_requested_file(self):
|
def test_requested_file(self):
|
||||||
file = self.addon.current_version.current_file
|
file = self.addon.current_version.current_file
|
||||||
|
@ -320,15 +309,6 @@ class TestFileEntriesDiffSerializer(TestCase):
|
||||||
assert data['base_file'] == {
|
assert data['base_file'] == {
|
||||||
'id': parent_version.current_file.pk
|
'id': parent_version.current_file.pk
|
||||||
}
|
}
|
||||||
assert data['status'] == 'public'
|
|
||||||
assert data['hash'] == ''
|
|
||||||
assert data['is_webextension'] is True
|
|
||||||
assert data['created'] == (
|
|
||||||
file.created.replace(microsecond=0).isoformat() + 'Z')
|
|
||||||
assert data['url'] == (
|
|
||||||
'http://testserver/firefox/downloads/file/{}'
|
|
||||||
'/webextension_no_id.xpi?src=').format(file.pk)
|
|
||||||
|
|
||||||
assert data['selected_file'] == 'manifest.json'
|
assert data['selected_file'] == 'manifest.json'
|
||||||
assert data['download_url'] == absolutify(reverse(
|
assert data['download_url'] == absolutify(reverse(
|
||||||
'reviewers.download_git_file',
|
'reviewers.download_git_file',
|
||||||
|
|
Загрузка…
Ссылка в новой задаче