Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Previously, your {{ type }} was suspended/removed from Mozilla Add-ons, based on

{% if not is_override %}After reviewing your appeal, we{% else %}We have now{% endif %} determined that the previous decision was incorrect, and based on that determination, we have restored your {{ type }}. It is now available at {{ target_url }}.
{% if manual_reasoning_text %}{{ manual_reasoning_text }}. {% endif %}
{% if version_list %}
The following versions were reinstated: {{ version_list }}.
Please note that these versions may be removed again in the future, if additional policy violations are discovered. {% endif %}

{% if has_attachment %}
An attachment was provided. {% if dev_url %}To respond or view the file, visit {{ dev_url }}.{% endif %}
Expand Down
71 changes: 71 additions & 0 deletions src/olympia/abuse/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from olympia.constants.permissions import ADDONS_HIGH_IMPACT_APPROVE
from olympia.constants.promoted import PROMOTED_GROUP_CHOICES
from olympia.core import set_user
from olympia.files.models import File
from olympia.ratings.models import Rating
from olympia.reviewers.models import NeedsHumanReview
from olympia.users.models import UserProfile
Expand Down Expand Up @@ -3357,6 +3358,76 @@ def test_execute_action_reject_version(self):
assert 'An attachment was provided.' not in mail.outbox[0].body
assert 'To respond or view the file,' not in mail.outbox[0].body

def _execute_action_approve_appeal(self, addon, appealed_decision_action):
older_version = addon.versions.last()
newer_version = addon.versions.first()
appeal_job = CinderJob.objects.create()
ContentDecision.objects.create(
addon=addon,
action=appealed_decision_action,
reasoning='initial review text',
appeal_job=appeal_job,
)
decision = ContentDecision.objects.create(
addon=addon,
action=DECISION_ACTIONS.AMO_APPROVE,
reasoning='some review text',
reviewer_user=self.reviewer_user,
cinder_job=appeal_job,
)
decision.target_versions.set([older_version, newer_version])
assert decision.action_date is None

decision.execute_action()
self.assertCloseToNow(decision.action_date)
assert older_version.file.reload().status == amo.STATUS_APPROVED
assert newer_version.file.reload().status == amo.STATUS_AWAITING_REVIEW

decision.send_notifications()
mail_item = mail.outbox[0]
assert 'some review text' in mail_item.body
assert 'An attachment was provided.' not in mail_item.body
assert 'To respond or view the file,' not in mail_item.body
assert (
'versions were reinstated: '
f'{older_version.version}, {newer_version.version}' in mail_item.body
)
assert 'versions may be removed again in the future' in mail_item.body

def test_execute_action_approve_appeal_on_disable(self):
addon = addon_factory(users=[user_factory()], status=amo.STATUS_DISABLED)
older_version = addon.versions.get()
older_version.file.update(
status=amo.STATUS_DISABLED,
original_status=amo.STATUS_APPROVED,
status_disabled_reason=File.STATUS_DISABLED_REASONS.ADDON_DISABLE,
)
version_factory(
addon=addon,
file_kw={
'status': amo.STATUS_DISABLED,
'original_status': amo.STATUS_AWAITING_REVIEW,
'status_disabled_reason': File.STATUS_DISABLED_REASONS.ADDON_DISABLE,
},
)
#
self._execute_action_approve_appeal(addon, DECISION_ACTIONS.AMO_DISABLE_ADDON)
assert addon.reload().status == amo.STATUS_APPROVED

def test_execute_action_approve_appeal_on_reject(self):
addon = addon_factory(users=[user_factory()])
older_version = addon.versions.get()
version_factory(
addon=addon
) # add a middle version that wasn't rejected or changed
older_version.file.update(
status=amo.STATUS_DISABLED, original_status=amo.STATUS_APPROVED
)
version_factory(addon=addon, file_kw={'status': amo.STATUS_DISABLED})
self._execute_action_approve_appeal(
addon, DECISION_ACTIONS.AMO_REJECT_VERSION_ADDON
)

def _test_execute_action_reject_version_delayed_outcome(self, decision):
decision.send_notifications()
assert 'appeal' not in mail.outbox[0].body
Expand Down
Loading