add a view for abuse reports (bug 676734)
This commit is contained in:
Родитель
75228f2b91
Коммит
7689f96802
|
@ -0,0 +1,32 @@
|
|||
{% extends "editors/base.html" %}
|
||||
|
||||
{% block title %}
|
||||
{{ editor_page_title(_('{addon} :: Abuse Reports')|f(addon=addon.name)) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
{{ editors_breadcrumbs() }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>{{_('Abuse Reports for {addon} ({num})')|f(addon=addon.name, num=total|numberfmt) }}</h2>
|
||||
<ul>
|
||||
{% for report in reports %}
|
||||
<li>
|
||||
{% with date=report.created|datetime, ip_address=report.ip_address %}
|
||||
{% if report.reporter %}
|
||||
{% trans user=report.reporter|user_link %}
|
||||
{{ user }} on {{ date }} [{{ ip_address }}]
|
||||
{% endtrans %}
|
||||
{% else %}
|
||||
{% trans %}
|
||||
<i>anonymous</i> on {{ date }} [{{ ip_address }}]
|
||||
{% endtrans %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
<blockquote>{{ report.message }}</blockquote>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{{ reports|paginator }}
|
||||
{% endblock %}
|
|
@ -17,6 +17,7 @@ import amo
|
|||
import amo.tests
|
||||
from amo.urlresolvers import reverse
|
||||
from amo.tests import formset, initial
|
||||
from abuse.models import AbuseReport
|
||||
from addons.models import Addon, AddonUser
|
||||
from applications.models import Application
|
||||
from devhub.models import ActivityLog
|
||||
|
@ -2114,3 +2115,23 @@ class TestStatusFile(ReviewBase):
|
|||
node = pq(res.content)('td.files div').eq(1)
|
||||
|
||||
assert unicode(amo.STATUS_CHOICES[self.file.status]) in node.text()
|
||||
|
||||
|
||||
class TestAbuseReports(amo.tests.TestCase):
|
||||
fixtures = ['base/users', 'base/addon_3615']
|
||||
|
||||
def setUp(self):
|
||||
user = UserProfile.objects.all()[0]
|
||||
AbuseReport.objects.create(addon_id=3615, message='woo')
|
||||
AbuseReport.objects.create(addon_id=3615, message='yeah',
|
||||
reporter=user)
|
||||
# Make a user abuse report to make sure it doesn't show up.
|
||||
AbuseReport.objects.create(user=user, message='hey now')
|
||||
|
||||
def test_abuse_reports_list(self):
|
||||
assert self.client.login(username='admin@mozilla.com',
|
||||
password='password')
|
||||
r = self.client.get(reverse('editors.abuse_reports', args=['a3615']))
|
||||
eq_(r.status_code, 200)
|
||||
# We see the two abuse reports created in setUp.
|
||||
eq_(len(r.context['reports']), 2)
|
||||
|
|
|
@ -6,6 +6,7 @@ from . import views
|
|||
|
||||
# All URLs under /editors/
|
||||
urlpatterns = (
|
||||
url(r'^$', views.home, name='editors.home'),
|
||||
url(r'^queue$', views.queue, name='editors.queue'),
|
||||
url(r'^queue/nominated$', views.queue_nominated,
|
||||
name='editors.queue_nominated'),
|
||||
|
@ -35,5 +36,6 @@ urlpatterns = (
|
|||
name='editors.performance'),
|
||||
url(r'^motd$', views.motd, name='editors.motd'),
|
||||
url(r'^motd/save$', views.save_motd, name='editors.save_motd'),
|
||||
url(r'^$', views.home, name='editors.home'),
|
||||
url(r'^abuse-reports/%s$' % ADDON_ID, views.abuse_reports,
|
||||
name='editors.abuse_reports'),
|
||||
)
|
||||
|
|
|
@ -15,6 +15,7 @@ import jingo
|
|||
from tower import ugettext as _
|
||||
|
||||
import amo
|
||||
from abuse.models import AbuseReport
|
||||
from access import acl
|
||||
from addons.decorators import addon_view
|
||||
from addons.models import Addon, Version
|
||||
|
@ -564,3 +565,13 @@ def reviewlog(request):
|
|||
}
|
||||
data = context(form=form, pager=pager, ACTION_DICT=ad)
|
||||
return jingo.render(request, 'editors/reviewlog.html', data)
|
||||
|
||||
|
||||
@editor_required
|
||||
@addon_view
|
||||
def abuse_reports(request, addon):
|
||||
reports = AbuseReport.objects.filter(addon=addon).order_by('-created')
|
||||
total = reports.count()
|
||||
reports = amo.utils.paginate(request, reports)
|
||||
return jingo.render(request, 'editors/abuse_reports.html',
|
||||
dict(addon=addon, reports=reports, total=total))
|
||||
|
|
Загрузка…
Ссылка в новой задаче