Remove unnecessary file properties from reviewers API responses (#14105)

This commit is contained in:
Bob Silverberg 2020-04-30 14:34:02 -04:00 коммит произвёл GitHub
Родитель c642718cb5
Коммит fed8ca24a3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 11 добавлений и 32 удалений

Просмотреть файл

@ -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 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 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.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.

Просмотреть файл

@ -49,7 +49,7 @@ class AddonReviewerFlagsSerializer(serializers.ModelSerializer):
# 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.
class FileEntriesSerializer(FileSerializer):
class FileEntriesSerializer(serializers.ModelSerializer):
content = serializers.SerializerMethodField()
uses_unknown_minified_code = serializers.SerializerMethodField()
download_url = serializers.SerializerMethodField()
@ -62,8 +62,7 @@ class FileEntriesSerializer(FileSerializer):
filename = serializers.SerializerMethodField()
class Meta:
fields = FileSerializer.Meta.fields + (
'content', 'entries', 'selected_file', 'download_url',
fields = ('id', 'content', 'entries', 'selected_file', 'download_url',
'uses_unknown_minified_code', 'mimetype', 'sha256', 'size',
'mime_category', 'filename'
)
@ -350,8 +349,7 @@ class FileEntriesDiffSerializer(FileEntriesSerializer):
base_file = serializers.SerializerMethodField()
class Meta:
fields = FileSerializer.Meta.fields + (
'diff', 'entries', 'selected_file', 'download_url',
fields = ('id', 'diff', 'entries', 'selected_file', 'download_url',
'uses_unknown_minified_code', 'base_file',
'sha256', 'size', 'mimetype', 'mime_category', 'filename'
)

Просмотреть файл

@ -60,15 +60,6 @@ class TestFileEntriesSerializer(TestCase):
data = self.serialize(file)
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['download_url'] == absolutify(reverse(
'reviewers.download_git_file',
@ -110,8 +101,6 @@ class TestFileEntriesSerializer(TestCase):
assert '"manifest_version": 2' 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):
file = self.addon.current_version.current_file
@ -320,15 +309,6 @@ class TestFileEntriesDiffSerializer(TestCase):
assert data['base_file'] == {
'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['download_url'] == absolutify(reverse(
'reviewers.download_git_file',