Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attachment Emails for Reviewer Attachments #22704

Merged
merged 8 commits into from
Sep 27, 2024
Merged
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
5 changes: 5 additions & 0 deletions src/olympia/abuse/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from olympia import amo
from olympia.addons.models import Addon
from olympia.amo.models import BaseQuerySet, ManagerBase, ModelBase
from olympia.amo.templatetags.jinja_helpers import absolutify
from olympia.api.utils import APIChoicesWithNone
from olympia.bandwagon.models import Collection
from olympia.constants.abuse import (
Expand Down Expand Up @@ -1241,6 +1242,10 @@ def notify_reviewer_decision(
# tools, we don't want to duplicate it as policies too.
'policies': policies if not self.notes else (),
'version_list': ', '.join(ver_str for ver_str in version_numbers),
'has_attachment': hasattr(log_entry, 'attachmentlog'),
'dev_url': absolutify(self.target.get_dev_url('versions'))
if self.addon_id
else None,
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Your add-on can be subject to human review at any time. Reviewers may determine
{% endif %}
{% if manual_reasoning_text %}Comments: {{ manual_reasoning_text }}.{% endif %}

{% if has_attachment %}
An attachment was provided. {% if dev_url %}To respond or view the file, visit {{ dev_url }}.{% endif %}

{% endif %}
Thank you.

More information about Mozilla's add-on policies can be found at {{ policy_document_url }}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Our review found that your content violates the following Mozilla policy or poli
{% include 'abuse/emails/includes/policies.txt' %}

Based on that finding, your {{ type }} has been permanently disabled on {{ target_url }} and is no longer available for download from Mozilla Add-ons, anywhere in the world. {% if is_addon_being_blocked %}In addition, users who have previously installed the add-on won't be able to continue using it.{% else %}Users who have previously installed your add-on will be able to continue using it.{% endif %}
{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ 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 has_attachment %}
An attachment was provided. {% if dev_url %}To respond or view the file, visit {{ dev_url }}.{% endif %}

{% endif %}
Thank you.

More information about Mozilla's add-on policies can be found at {{ policy_document_url }}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Previously, your {{ type }} was suspended/removed from Mozilla Add-ons, based on

After reviewing your appeal, we determined that the previous decision, that your {{ type }} violates Mozilla's policies, was correct. {% if manual_reasoning_text %}{{ manual_reasoning_text }}. {% endif %}Based on that determination, we have denied your appeal, and will not reinstate your {{ type }}.

{% if has_attachment %}
An attachment was provided. {% if dev_url %}To respond or view the file, visit {{ dev_url }}.{% endif %}

{% endif %}
chrstinalin marked this conversation as resolved.
Show resolved Hide resolved
More information about Mozilla's add-on policies can be found at {{ policy_document_url }}.

Thank you.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
- {{ policy.full_text|safe }}
{% endfor %}
{% if manual_reasoning_text %}{{ manual_reasoning_text|safe }}. {% endif %}

{% if has_attachment %}
An attachment was provided. {% if dev_url %}To respond or view the file, visit {{ dev_url }}.{% endif %}

{% endif %}
15 changes: 14 additions & 1 deletion src/olympia/abuse/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
from django.conf import settings
from django.core import mail
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.core.files.base import ContentFile
from django.db.utils import IntegrityError

import pytest
import responses
from waffle.testutils import override_switch

from olympia import amo
from olympia.activity.models import ActivityLog
from olympia.activity.models import ActivityLog, AttachmentLog
from olympia.addons.models import Addon
from olympia.amo.tests import (
TestCase,
Expand Down Expand Up @@ -2746,6 +2747,18 @@ def _test_notify_reviewer_decision(
assert 'days' not in mail.outbox[0].body
assert 'some review text' in mail.outbox[0].body
assert 'some policy text' not in mail.outbox[0].body
AttachmentLog.objects.create(
activity_log=log_entry,
file=ContentFile('Pseudo File', name='attachment.txt'),
)
eviljeff marked this conversation as resolved.
Show resolved Hide resolved
decision.notify_reviewer_decision(
log_entry=log_entry,
entity_helper=entity_helper,
)
assert 'An attachment was provided.' not in mail.outbox[0].body
assert 'To respond or view the file,' not in mail.outbox[0].body
assert 'An attachment was provided.' in mail.outbox[1].body
assert 'To respond or view the file,' in mail.outbox[1].body
else:
assert len(mail.outbox) == 0

Expand Down
Loading