Skip to content

Commit

Permalink
allow approval notes to be set by developers via the addon submission…
Browse files Browse the repository at this point in the history
… api (#19579)

* allow approval notes to be set by developers via the addon submission api

* don't commit migration yet
  • Loading branch information
eviljeff authored Aug 19, 2022
1 parent 26f2382 commit 1d71d12
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 13 deletions.
5 changes: 4 additions & 1 deletion docs/topics/api/addons.rst
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ This endpoint allows you to fetch a single version belonging to a specific add-o

:query string lang: Activate translations in the specific language for that query. (See :ref:`translated fields <api-overview-translations>`)
:>json int id: The version id.
:>json string approval_notes: Information for Mozilla reviewers, for when the add-on is reviewed. These notes are only visible to Mozilla, and this field is only present if the user has reviewer permissions, or is listed as a developer of the add-on.
:>json string channel: The version channel, which determines its visibility on the site. Can be either ``unlisted`` or ``listed``.
:>json object compatibility:
Object detailing which :ref:`applications <addon-detail-application>` the version is compatible with.
Expand Down Expand Up @@ -574,6 +575,7 @@ already defined.
.. _version-create-request:

:<json string approval_notes: Information for Mozilla reviewers, for when the add-on is reviewed. These notes are only visible to Mozilla.
:<json object|array compatibility:
Either an object detailing which :ref:`applications <addon-detail-application>`
and versions the version is compatible with; or an array of :ref:`applications <addon-detail-application>`,
Expand All @@ -584,8 +586,8 @@ already defined.
:<json object|null custom_license.name: The name of the license (See :ref:`translated fields <api-overview-translations>`). Custom licenses are not supported for themes.
:<json object|null custom_license.text: The text of the license (See :ref:`translated fields <api-overview-translations>`). Custom licenses are not supported for themes.
:<json object|null release_notes: The release notes for this version (See :ref:`translated fields <api-overview-translations>`).
:<json string upload: The uuid for the xpi upload to create this version with.
:<json string|null source: The submitted source for this version. As JSON this field can only be set to null, to clear it - see :ref:`uploading source <version-sources>` to set/update the source file.
:<json string upload: The uuid for the xpi upload to create this version with.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -690,6 +692,7 @@ This endpoint allows the metadata for an existing version to be edited.
.. _version-edit-request:

:<json string approval_notes: Information for Mozilla reviewers, for when the add-on is reviewed. These notes are only visible to Mozilla.
:<json object|array compatibility: Either an object detailing which :ref:`applications <addon-detail-application>` and versions the version is compatible with; or an array of :ref:`applications <addon-detail-application>`, where default min/max versions will be used if not already defined. See :ref:`examples <version-compatibility-examples>`.
:<json string compatibility[app_name].max: Maximum version of the corresponding app the version is compatible with. Should only be enforced by clients if ``is_strict_compatibility_enabled`` is ``true``.
:<json string compatibility[app_name].min: Minimum version of the corresponding app the version is compatible with.
Expand Down
1 change: 1 addition & 0 deletions docs/topics/api/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ These are `v5` specific changes - `v4` changes apply also.
* 2022-05-12: added the ability to add new add-on authors, as pending authors. https://github.com/mozilla/addons-server/issues/19164
* 2022-06-02: enabled setting ``default_locale`` via addon submission and edit endpoints. https://github.com/mozilla/addons-server/issues/18235
* 2022-06-16: added the ability to "PUT" an add-on upload to either create or update an add-on. https://github.com/mozilla/addons-server/issues/15353
* 2022-08-25: added ``approval_notes`` for version create or edit, and exposed via the version detail response for authorized developers of the add-on and reviewers. https://github.com/mozilla/addons-server/issues/19554

.. _`#11380`: https://github.com/mozilla/addons-server/issues/11380/
.. _`#11379`: https://github.com/mozilla/addons-server/issues/11379/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": null,
"created": "2010-09-12 07:17:04",
"release_notes": null,
"approval_notes": null,
"approval_notes": "",
"modified": "2010-09-12 07:17:04",
"version": "1.0",
"addon": 228106
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": null,
"created": "2010-09-12 07:17:04",
"release_notes": null,
"approval_notes": null,
"approval_notes": "",
"modified": "2010-09-12 07:17:04",
"version": "1.0",
"addon": 228107
Expand Down
4 changes: 2 additions & 2 deletions src/olympia/addons/fixtures/addons/listed-two-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"license": 5,
"created": "2009-12-13 23:10:16",
"release_notes": null,
"approval_notes": null,
"approval_notes": "",
"modified": "2009-12-13 23:11:17",
"version": "1.0",
"addon": 2795
Expand All @@ -57,7 +57,7 @@
"license": 5,
"created": "2009-12-13 23:10:16",
"release_notes": null,
"approval_notes": null,
"approval_notes": "",
"modified": "2009-12-14 17:43:48",
"version": "2.0",
"addon": 2795
Expand Down
2 changes: 1 addition & 1 deletion src/olympia/addons/fixtures/addons/listed.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"license": 5,
"created": "2010-03-24 16:33:19",
"release_notes": null,
"approval_notes": null,
"approval_notes": "",
"modified": "2010-03-24 16:35:26",
"version": "0",
"addon": 3723
Expand Down
3 changes: 3 additions & 0 deletions src/olympia/addons/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ def __init__(self, instance=None, data=serializers.empty, **kwargs):


class DeveloperVersionSerializer(VersionSerializer):
approval_notes = serializers.CharField(allow_blank=True, required=False)
custom_license = LicenseSerializer(
write_only=True,
required=False,
Expand All @@ -424,6 +425,7 @@ class Meta:
)
fields = (
'id',
'approval_notes',
'channel',
'compatibility',
'custom_license',
Expand All @@ -438,6 +440,7 @@ class Meta:
'version',
)
writeable_fields = (
'approval_notes',
'compatibility',
'custom_license',
'license',
Expand Down
9 changes: 9 additions & 0 deletions src/olympia/addons/tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,15 @@ def test_source(self):
reverse('downloads.source', args=(self.version.id,))
)

def test_approval_notes(self):
self.version = addon_factory().current_version
result = self.serialize()
assert result['approval_notes'] == ''

self.version.update(approval_notes='Plz approve!')
result = self.serialize()
assert result['approval_notes'] == 'Plz approve!'


class TestListVersionSerializerOutput(TestCase):
serializer_class = ListVersionSerializer
Expand Down
9 changes: 8 additions & 1 deletion src/olympia/addons/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3147,6 +3147,7 @@ def test_set_extra_data(self):
data={
**self.minimal_data,
'release_notes': {'en-US': 'dsdsdsd'},
'approval_notes': 'This!',
},
)

Expand All @@ -3157,6 +3158,7 @@ def test_set_extra_data(self):
version = self.addon.find_latest_version(channel=None)
assert data['release_notes'] == {'en-US': 'dsdsdsd'}
assert version.release_notes == 'dsdsdsd'
assert version.approval_notes == 'This!'
self.statsd_incr_mock.assert_any_call('addons.submission.version.unlisted')

def test_check_blocklist(self):
Expand Down Expand Up @@ -3358,14 +3360,19 @@ def setUp(self):
def test_basic(self):
response = self.client.patch(
self.url,
data={'release_notes': {'en-US': 'Something new'}},
data={
'release_notes': {'en-US': 'Something new'},
'approval_notes': 'secret!',
},
)
assert response.status_code == 200, response.content
data = response.data
assert data['release_notes'] == {'en-US': 'Something new'}
assert data['approval_notes'] == 'secret!'
self.addon.reload()
self.version.reload()
assert self.version.release_notes == 'Something new'
assert self.version.approval_notes == 'secret!'
assert self.addon.versions.count() == 1
version = self.addon.find_latest_version(channel=None)
request = APIRequestFactory().get('/')
Expand Down
2 changes: 1 addition & 1 deletion src/olympia/amo/fixtures/base/addon_3723_listed.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"created": "2010-01-03 21:26:09",
"release_notes": null,
"modified": "2010-01-03 22:13:50",
"approval_notes": null,
"approval_notes": "",
"version": "0",
"addon": 3723
}
Expand Down
2 changes: 1 addition & 1 deletion src/olympia/amo/fixtures/base/featured.json
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
"license": 6,
"created": "2009-05-08 05:26:21",
"release_notes": null,
"approval_notes": null,
"approval_notes": "",
"modified": "2009-05-08 05:26:21",
"version": "0.5.3",
"addon": 11870
Expand Down
6 changes: 2 additions & 4 deletions src/olympia/versions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@ class Version(OnChangeMixin, ModelBase):
'License', null=True, blank=True, on_delete=models.SET_NULL
)
release_notes = PurifiedField(db_column='releasenotes', short=False)
approval_notes = models.TextField(
db_column='approvalnotes', default='', null=True, blank=True
)
approval_notes = models.TextField(db_column='approvalnotes', default='', blank=True)
version = VersionStringField(max_length=255, default='0.1')

nomination = models.DateTimeField(null=True)
Expand Down Expand Up @@ -339,7 +337,7 @@ def from_upload(
previous_version = addon.find_latest_version(channel=channel, exclude=())
if previous_version and previous_version.license_id:
license_id = previous_version.license_id
approval_notes = None
approval_notes = parsed_data.get('approval_notes', '')
if parsed_data.get('is_mozilla_signed_extension'):
approval_notes = (
'This version has been signed with Mozilla internal certificate.'
Expand Down

0 comments on commit 1d71d12

Please sign in to comment.