Add addon_install_source_url parameter to abuse report API

This commit is contained in:
Mathieu Pillard 2020-02-12 11:33:20 +01:00
Родитель 1cdf2c497e
Коммит 66a19078e5
7 изменённых файлов: 40 добавлений и 2 удалений

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

@ -38,8 +38,9 @@ to if necessary.
:<json string message: The body/content of the abuse report (required).
:<json string|null report_entry_point: The report entry point. The accepted values are documented in the :ref:`table below <abuse-report_entry_point-parameter>`.
:<json string|null addon_install_method: The add-on install method. The accepted values are documented in the :ref:`table below <abuse-addon_install_method-parameter>`.
:<json string|null addon_install_source: The add-on install source. The accepted values are documented in the :ref:`table below <abuse-addon_install_source-parameter>`.
:<json string|null addon_install_origin: The add-on install origin.
:<json string|null addon_install_source: The add-on install source. The accepted values are documented in the :ref:`table below <abuse-addon_install_source-parameter>`.
:<json string|null addon_install_source_url: The add-on install source URL.
:<json string|null addon_name: The add-on name in the locale used by the client.
:<json string|null addon_signature: The add-on signature state. The accepted values are documented in the :ref:`table below <abuse-addon_signature-parameter>`.
:<json string|null addon_summary: The add-on summary in the locale used by the client.
@ -64,8 +65,9 @@ to if necessary.
:>json string message: The body/content of the abuse report.
:>json string|null report_entry_point: The report entry point.
:>json string|null addon_install_method: The add-on install method.
:>json string|null addon_install_source: The add-on install source.
:>json string|null addon_install_origin: The add-on install origin.
:>json string|null addon_install_source: The add-on install source.
:>json string|null addon_install_source_url: The add-on install source URL.
:>json string|null addon_name: The add-on name in the locale used by the client.
:>json string|null addon_signature: The add-on signature state.
:>json string|null addon_summary: The add-on summary in the locale used by the client.

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

@ -346,6 +346,7 @@ v4 API changelog
* 2019-02-21: added new /api/v4/reviewers/addon/(addon_id)/versions/ endpoint. https://github.com/mozilla/addons-server/issues/10432
* 2019-03-14: added new /reviewers/compare/ endpoint. https://github.com/mozilla/addons-server/issues/10323
* 2019-04-11: removed ``id``, ``username`` and ``url`` from the ``user`` object in the activity review notes APIs. https://github.com/mozilla/addons-server/issues/11002
* 2019-04-18: added new optional parameters to abuse report endpoint
* 2019-05-09: added ``is_recommended`` to addons API. https://github.com/mozilla/addons-server/issues/11278
* 2019-05-16: added /reviewers/canned-responses/ endpoint. https://github.com/mozilla/addons-server/issues/11276
* 2019-05-23: added ``is_recommended`` to addons autocomplete API also. https://github.com/mozilla/addons-server/issues/11439
@ -368,6 +369,7 @@ v4 API changelog
* 2019-12-05: removed /addons/featured endpoint from v4+ and featured support from other addon api endpoints. https://github.com/mozilla/addons-server/issues/12937
* 2020-01-23: added /scanner/results (internal API endpoint).
* 2020-02-06: added /reviewers/addon/(int:addon_id)/allow_resubmission/ and /reviewers/addon/(int:addon_id)/deny_resubmission/. https://github.com/mozilla/addons-server/issues/13409
* 2020-02-20: added ``addon_install_source_url`` to abuse report endpoint
.. _`#11380`: https://github.com/mozilla/addons-server/issues/11380/
.. _`#11379`: https://github.com/mozilla/addons-server/issues/11379/

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

@ -0,0 +1,18 @@
# Generated by Django 2.2.9 on 2020-02-12 10:32
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('abuse', '0002_add_amo_entrypoint'),
]
operations = [
migrations.AddField(
model_name='abusereport',
name='addon_install_source_url',
field=models.CharField(blank=True, default=None, max_length=255, null=True),
),
]

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

@ -178,6 +178,10 @@ class AbuseReport(ModelBase):
reason = models.PositiveSmallIntegerField(
default=None, choices=REASONS.choices, blank=True, null=True)
addon_install_origin = models.CharField(
# Supposed to be an URL, but the scheme could be moz-foo: or something
# like that, and it's potentially truncated, so use a CharField and not
# a URLField. We also don't want to automatically turn this into a
# clickable link in the admin in case it's dangerous.
default=None, max_length=255, blank=True, null=True)
addon_install_method = models.PositiveSmallIntegerField(
default=None, choices=ADDON_INSTALL_METHODS.choices, blank=True,
@ -185,6 +189,9 @@ class AbuseReport(ModelBase):
addon_install_source = models.PositiveSmallIntegerField(
default=None, choices=ADDON_INSTALL_SOURCES.choices, blank=True,
null=True)
addon_install_source_url = models.CharField(
# See addon_install_origin above as for why it's not an URLField.
default=None, max_length=255, blank=True, null=True)
report_entry_point = models.PositiveSmallIntegerField(
default=None, choices=REPORT_ENTRY_POINTS.choices, blank=True,
null=True)
@ -214,6 +221,7 @@ class AbuseReport(ModelBase):
'application_locale', 'operating_system',
'operating_system_version', 'install_date', 'reason',
'addon_install_origin', 'addon_install_method',
'addon_install_source', 'addon_install_source_url',
'report_entry_point'
)
for field_name in field_names:

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

@ -82,6 +82,7 @@ class AddonAbuseReportSerializer(BaseAbuseReportSerializer):
'addon_install_method',
'addon_install_origin',
'addon_install_source',
'addon_install_source_url',
'addon_name',
'addon_signature',
'addon_summary',

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

@ -34,6 +34,7 @@ class TestAddonAbuseReportSerializer(TestCase):
'addon_install_method': None,
'addon_install_origin': None,
'addon_install_source': None,
'addon_install_source_url': None,
'addon_name': None,
'addon_signature': None,
'addon_summary': None,
@ -63,6 +64,7 @@ class TestAddonAbuseReportSerializer(TestCase):
'addon_install_method': None,
'addon_install_origin': None,
'addon_install_source': None,
'addon_install_source_url': None,
'addon_name': None,
'addon_signature': None,
'addon_summary': None,
@ -97,6 +99,7 @@ class TestAddonAbuseReportSerializer(TestCase):
'addon_install_method': 'url',
'addon_install_origin': 'http://somewhere.com/',
'addon_install_source': 'amo',
'addon_install_source_url': 'https://example.com/sourceme',
'addon_name': u'Fancy add-on nâme',
'addon_signature': None,
'addon_summary': u'A summary',
@ -118,6 +121,7 @@ class TestAddonAbuseReportSerializer(TestCase):
'addon_install_method': AbuseReport.ADDON_INSTALL_METHODS.URL,
'addon_install_origin': 'http://somewhere.com/',
'addon_install_source': AbuseReport.ADDON_INSTALL_SOURCES.AMO,
'addon_install_source_url': 'https://example.com/sourceme',
'addon_name': u'Fancy add-on nâme',
'addon_signature': None,
'addon_summary': 'A summary',

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

@ -243,6 +243,7 @@ class AddonAbuseViewSetTestBase(object):
assert report.addon_install_method == (
AbuseReport.ADDON_INSTALL_METHODS.URL)
assert report.addon_install_source is None
assert report.addon_install_source_url is None
assert report.report_entry_point is None
def test_optional_fields_errors(self):
@ -263,6 +264,7 @@ class AddonAbuseViewSetTestBase(object):
'addon_install_origin': 'u' * 256,
'addon_install_method': 'Something not in install method choices',
'addon_install_source': 'Something not in install source choices',
'addon_install_source_url': 'http://%s' % 'a' * 249,
'report_entry_point': 'Something not in entrypoint choices',
}
response = self.client.post(
@ -289,6 +291,7 @@ class AddonAbuseViewSetTestBase(object):
'instead: YYYY-MM-DDThh:mm[:ss[.uuuuuu]][+HH:MM|-HH:MM|Z].'],
'reason': [expected_choices_message % data['reason']],
'addon_install_origin': [expected_max_length_message % 255],
'addon_install_source_url': [expected_max_length_message % 255],
'report_entry_point': [
expected_choices_message % data['report_entry_point']],
}