Display more data about abuse reports in reviewer tools

This commit is contained in:
Mathieu Pillard 2019-04-24 17:33:20 +02:00
Родитель 7a4e2e64d1
Коммит 129a1c0da9
5 изменённых файлов: 142 добавлений и 33 удалений

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

@ -666,7 +666,6 @@ MINIFY_BUNDLES = {
'zamboni/reviewers': (
'css/zamboni/reviewers.less',
'css/zamboni/unlisted.less',
'css/zamboni/reviewers.less',
),
'zamboni/themes_review': (
'css/zamboni/developers.css',

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

@ -5,7 +5,11 @@
{% endblock %}
{% block content %}
<h2>{{_('Abuse Reports for {addon} and its developers ({num})')|format_html(addon=addon.name, num=reports.paginator.count|numberfmt) }}</h2>
<hgroup>
<h2>{{_('Abuse Reports for {addon} and its developers ({num})')|format_html(addon=addon.name, num=reports.paginator.count|numberfmt) }}</h2>
</hgroup>
{% include 'reviewers/addon_details_box.html' %}
<h3>{{ _('Abuse Reports') }}</h3>
{% include "reviewers/includes/abuse_reports_list.html" %}
{{ reports|paginator }}
{% endblock %}

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

@ -1,20 +1,62 @@
<ul class="abuse_reports">
<table class="abuse_reports">
<thead>
<tr>
<th> Target </th>
<th> Application </th>
<th> Install date </th>
<th> Install origin </th>
<th> Category </th>
<th> Date </th>
<th> Reporter </th>
</tr>
</thead>
{% for report in reports %}
<li>
{% if report.reporter %}
{% set user_link = report.reporter|user_link %}
{% else %}
{% set user_link = "<i>anonymous</i>"|safe %}
<thead>
<tr>
<td>
{% if report.addon %}
{% set object_name = report.addon.name %}
{% else %}
{% set object_name = report.user|user_link %}
{% endif %}
{{ object_name }} {{ report.addon_version }}
</td>
<td>
{{ report.get_application_display() }}
{{ report.application_version }}
{{ report.application_locale }}
{{ report.operating_system }}
{{ report.operating_system_version }}
</td>
<td>
{% if report.install_date %}
{% set report_install_date = report.install_date.replace(microsecond=0).isoformat() %}
{% else %}
{% set report_install_date = '' %}
{% endif %}
{% if report_install_date %}
<time datetime="{{ report_install_date }}" title="{{ report_install_date }}">{{ report.install_date|timesince }}</time>
{% endif %}
</td>
<td>{{ report.addon_install_origin }} {{ report.get_addon_install_method_display() }}</td>
<td>{{ report.get_reason_display() }}</td>
<td>{{ report.created|datetime }}</td>
<td>
{% if report.reporter %}
{% set user_link = report.reporter|user_link %}
{% else %}
{% set user_link = "<i>anonymous</i>"|safe %}
{% endif %}
{{ user_link }} [{{ report.country_code }}]
</td>
</tr>
</thead>
{% if report.message %}
<tbody class="message">
<tr>
<td colspan="7">{{ report.message }}</td>
</tr>
</tbody>
{% endif %}
{% if report.addon %}
{% set object_name = report.addon.name %}
{% else %}
{% set object_name = report.user|user_link %}
{% endif %}
{% trans user=user_link, date=report.created|date, country_code=report.country_code, object=object_name %}
{{ user }} [{{ country_code }}] reported {{ object }} on {{ date }}
{% endtrans %}
<blockquote>{{ report.message }}</blockquote>
</li>
{% endfor %}
</ul>
</table>

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

@ -12,7 +12,6 @@ from django.core import mail
from django.core.cache import cache
from django.core.files import temp
from django.core.files.base import File as DjangoFile
from django.template import defaultfilters
from django.test.utils import override_settings
import mock
@ -32,6 +31,7 @@ from olympia.activity.models import ActivityLog
from olympia.addons.models import (
Addon, AddonApprovalsCounter, AddonReviewerFlags, AddonUser)
from olympia.amo.storage_utils import copy_stored_file
from olympia.amo.templatetags.jinja_helpers import format_date, format_datetime
from olympia.amo.tests import (
APITestClient, TestCase, addon_factory, check_links, file_factory, formset,
initial, reverse_ns, user_factory, version_factory)
@ -4163,9 +4163,25 @@ class TestReview(ReviewBase):
def test_abuse_reports(self):
report = AbuseReport.objects.create(
addon=self.addon, message=u'Et mël mazim ludus.',
country_code='FR')
created_at = defaultfilters.date(report.created)
addon=self.addon,
message=u'Et mël mazim ludus.',
country_code='FR',
client_id='4815162342',
addon_name='Unused here',
addon_summary='Not used either',
addon_version='42.0',
addon_signature=AbuseReport.ADDON_SIGNATURES.UNSIGNED,
application=amo.ANDROID.id,
application_locale='fr_FR',
operating_system='Løst OS',
operating_system_version='20040922',
install_date=self.days_ago(1),
reason=AbuseReport.REASONS.OFFENSIVE,
addon_install_origin='https://example.com/',
addon_install_method=AbuseReport.ADDON_INSTALL_METHODS.LINK,
report_entry_point=AbuseReport.REPORT_ENTRY_POINTS.MENU,
)
created_at = format_datetime(report.created)
response = self.client.get(self.url)
assert response.status_code == 200
doc = pq(response.content)
@ -4183,16 +4199,31 @@ class TestReview(ReviewBase):
assert response.status_code == 200
doc = pq(response.content)
assert doc('.abuse_reports')
assert (
doc('.abuse_reports').text() ==
u'anonymous [FR] reported Public on %s\nEt mël mazim ludus.'
% created_at)
expected = [
'Target',
'Application',
'Install date',
'Install origin',
'Category',
'Date',
'Reporter',
'Public 42.0',
'Firefox for Android fr_FR Løst OS 20040922',
'1\xa0day ago',
'https://example.com/ Direct link',
'Hateful, violent, or illegal content',
created_at,
'anonymous [FR]',
'Et mël mazim ludus.',
]
assert doc('.abuse_reports').text().split('\n') == expected
def test_abuse_reports_developers(self):
report = AbuseReport.objects.create(
user=self.addon.listed_authors[0], message=u'Foo, Bâr!',
country_code='DE')
created_at = defaultfilters.date(report.created)
created_at = format_datetime(report.created)
AutoApprovalSummary.objects.create(
verdict=amo.AUTO_APPROVED, version=self.version)
self.grant_permission(self.reviewer, 'Addons:PostReview')
@ -4200,17 +4231,31 @@ class TestReview(ReviewBase):
assert response.status_code == 200
doc = pq(response.content)
assert doc('.abuse_reports')
assert (
doc('.abuse_reports').text() ==
u'anonymous [DE] reported regularuser التطب on %s\nFoo, Bâr!'
% created_at)
expected = [
'Target',
'Application',
'Install date',
'Install origin',
'Category',
'Date',
'Reporter',
'regularuser التطب',
'Firefox',
'None',
'None',
created_at,
'anonymous [DE]',
'Foo, Bâr!',
]
assert doc('.abuse_reports').text().split('\n') == expected
def test_user_ratings(self):
user = user_factory()
rating = Rating.objects.create(
body=u'Lôrem ipsum dolor', rating=3, ip_address='10.5.6.7',
addon=self.addon, user=user)
created_at = defaultfilters.date(rating.created)
created_at = format_date(rating.created)
Rating.objects.create( # Review with no body, ignored.
rating=1, addon=self.addon, user=user_factory())
Rating.objects.create( # Reply to a review, ignored.

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

@ -1174,3 +1174,22 @@ h2.addon {
}
}
}
table.abuse_reports {
width: 100%;
border-collapse: separate;
border-spacing: 0 0.5em;
tr, td, th {
border: 1px solid #333;
}
.message td, .message tr {
border: 0;
padding: 0 0 1.5em 0;
}
td+td, th+th {
border-left: 0;
}
}