filter down flagged by the site type (bug 813320)
This commit is contained in:
Родитель
803b36e5ad
Коммит
b1ffbc66ee
|
@ -94,10 +94,11 @@ class TestFlagged(amo.tests.TestCase):
|
|||
def setUp(self):
|
||||
super(TestFlagged, self).setUp()
|
||||
self.client.login(username='admin@mozilla.com', password='password')
|
||||
self.url = reverse('zadmin.flagged')
|
||||
|
||||
@mock.patch.object(settings, 'MARKETPLACE', False)
|
||||
def test_get(self):
|
||||
url = reverse('zadmin.flagged')
|
||||
response = self.client.get(url, follow=True)
|
||||
response = self.client.get(self.url, follow=True)
|
||||
|
||||
addons = dict((a.id, a) for a in response.context['addons'])
|
||||
eq_(len(addons), 3)
|
||||
|
@ -124,21 +125,32 @@ class TestFlagged(amo.tests.TestCase):
|
|||
Approval.objects.filter(addon=addon).latest().id)
|
||||
eq_(addons[3].version, None)
|
||||
|
||||
@mock.patch.object(settings, 'MARKETPLACE', False)
|
||||
def test_post(self):
|
||||
# Do a get first so the query is cached.
|
||||
url = reverse('zadmin.flagged')
|
||||
self.client.get(url, follow=True)
|
||||
response = self.client.post(self.url, {'addon_id': ['1', '2']},
|
||||
follow=True)
|
||||
self.assertRedirects(response, self.url)
|
||||
|
||||
response = self.client.post(url, {'addon_id': ['1', '2']}, follow=True)
|
||||
self.assertRedirects(response, url)
|
||||
|
||||
assert not Addon.objects.get(id=1).admin_review
|
||||
assert not Addon.objects.get(id=2).admin_review
|
||||
assert not Addon.uncached.get(id=1).admin_review
|
||||
assert not Addon.uncached.get(id=2).admin_review
|
||||
|
||||
addons = response.context['addons']
|
||||
eq_(len(addons), 1)
|
||||
eq_(addons[0], Addon.objects.get(id=3))
|
||||
|
||||
@mock.patch.object(settings, 'MARKETPLACE', False)
|
||||
def test_empty(self):
|
||||
Addon.objects.update(admin_review=False)
|
||||
res = self.client.get(self.url)
|
||||
eq_(set(res.context['addons']), set([]))
|
||||
|
||||
@mock.patch.object(settings, 'MARKETPLACE', False)
|
||||
def test_addons_only(self):
|
||||
Addon.objects.get(id=2).update(type=amo.ADDON_WEBAPP)
|
||||
res = self.client.get(self.url)
|
||||
eq_(set([r.pk for r in res.context['addons']]),
|
||||
set([1, 3]))
|
||||
|
||||
|
||||
class BulkValidationTest(amo.tests.TestCase):
|
||||
fixtures = ['base/apps', 'base/platforms', 'base/addon_3615',
|
||||
|
|
|
@ -74,17 +74,22 @@ else:
|
|||
|
||||
@admin_required(reviewers=True)
|
||||
def flagged(request):
|
||||
addons = Addon.objects.filter(admin_review=True).order_by('-created')
|
||||
types = (amo.MARKETPLACE_TYPES if settings.MARKETPLACE
|
||||
else list(set(amo.ADDON_TYPES.keys()) -
|
||||
set(amo.MARKETPLACE_TYPES)))
|
||||
addons = (Addon.uncached.filter(admin_review=True, type__in=types)
|
||||
.no_transforms().order_by('-created'))
|
||||
|
||||
if request.method == 'POST':
|
||||
ids = map(int, request.POST.getlist('addon_id'))
|
||||
addons = list(addons)
|
||||
Addon.objects.filter(id__in=ids).update(admin_review=False)
|
||||
# The sql update doesn't invalidate anything, do it manually.
|
||||
invalid = [addon for addon in addons if addon.pk in ids]
|
||||
Addon.objects.invalidate(*invalid)
|
||||
for addon in addons.filter(id__in=ids):
|
||||
addon.update(admin_review=False)
|
||||
return redirect('zadmin.flagged')
|
||||
|
||||
if not addons:
|
||||
return jingo.render(request, 'zadmin/flagged_addon_list.html',
|
||||
{'addons': addons})
|
||||
|
||||
sql = """SELECT {t}.* FROM {t} JOIN (
|
||||
SELECT addon_id, MAX(created) AS created
|
||||
FROM {t}
|
||||
|
@ -853,6 +858,7 @@ def generate_error(request):
|
|||
form.explode()
|
||||
return jingo.render(request, 'zadmin/generate-error.html', {'form': form})
|
||||
|
||||
|
||||
@any_permission_required([('Admin', '%'),
|
||||
('MailingLists', 'View')])
|
||||
def export_email_addresses(request):
|
||||
|
|
Загрузка…
Ссылка в новой задаче