alter all files if a nominated review and a self review flag (bug 637959)

This commit is contained in:
Andy McKay 2011-03-02 12:06:40 -08:00
Родитель d7b3f6da69
Коммит fbdbb0ca8e
5 изменённых файлов: 53 добавлений и 17 удалений

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

@ -305,7 +305,7 @@ class ReviewAddon(ReviewBase):
self.addon.status = amo.STATUS_PUBLIC
self.addon.save()
self.set_files(amo.STATUS_PUBLIC, self.data['files'],
self.set_files(amo.STATUS_PUBLIC, self.version.files.all(),
copy_to_mirror=True)
self.log_status()
@ -321,7 +321,7 @@ class ReviewAddon(ReviewBase):
self.addon.status = amo.STATUS_NULL
self.addon.save()
self.set_files(amo.STATUS_DISABLED, self.data['files'],
self.set_files(amo.STATUS_DISABLED, self.version.files.all(),
hide_disabled_file=True)
self.log_status()
@ -347,7 +347,7 @@ class ReviewAddon(ReviewBase):
self.addon.status = amo.STATUS_LITE
self.addon.save()
self.set_files(amo.STATUS_LITE, self.data['files'],
self.set_files(amo.STATUS_LITE, self.version.files.all(),
copy_to_mirror=True)
self.log_status()

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

@ -246,13 +246,34 @@ class TestReviewHelper(test_utils.TestCase):
self.helper.handler.notify_email(template, 'Sample subject %s, %s')
eq_(len(mail.outbox), 1)
def setup_data(self, status):
def setup_data(self, status, delete=[]):
mail.outbox = []
ActivityLog.objects.for_addons(self.helper.addon).delete()
self.file.update(status=status)
self.addon.status = status
self.helper = self.get_helper()
self.helper.set_data(self.get_data())
data = self.get_data().copy()
for key in delete:
del data[key]
self.helper.set_data(data)
def test_nomination_to_public_no_files(self):
for status in NOMINATED_STATUSES:
self.setup_data(status, ['files'])
self.helper.handler.process_public()
eq_(self.addon.versions.all()[0].files.all()[0].status,
amo.STATUS_PUBLIC)
def test_nomination_to_public_and_current_version(self):
for status in NOMINATED_STATUSES:
self.setup_data(status, ['files'])
self.addon.update(_current_version=None)
addon = Addon.objects.get(pk=3615)
assert not addon.current_version
self.helper.handler.process_public()
assert addon.current_version
def test_nomination_to_public(self):
for status in NOMINATED_STATUSES:
@ -374,8 +395,8 @@ class TestReviewHelper(test_utils.TestCase):
def test_nomination_to_super_review_and_escalate(self):
# Note we are changing the file status here.
for file_status in (amo.STATUS_PENDING, amo.STATUS_UNREVIEWED):
self.file.update(status=file_status)
self.setup_data(amo.STATUS_LITE)
self.file.update(status=file_status)
self.helper.handler.process_super_review()
eq_(self.addon.admin_review, True)

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

@ -4,8 +4,10 @@ import re
import time
from datetime import datetime, timedelta
from django.conf import settings
from django.core import mail
from mock import patch_object
from nose.tools import eq_
from pyquery import PyQuery as pq
import test_utils
@ -703,11 +705,18 @@ class TestReview(ReviewBase):
response = self.client.get(self.url)
eq_(response.status_code, 302)
@patch_object(settings._wrapped, 'SELF_REVIEW_ALLOWED', False)
def test_not_author(self):
AddonUser.objects.create(addon=self.addon, user=self.editor)
response = self.client.get(self.url)
eq_(response.status_code, 302)
@patch_object(settings._wrapped, 'SELF_REVIEW_ALLOWED', True)
def test_not_author(self):
AddonUser.objects.create(addon=self.addon, user=self.editor)
response = self.client.get(self.url)
eq_(response.status_code, 200)
def test_not_flags(self):
response = self.client.get(self.url)
eq_(len(response.context['flags']), 0)

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

@ -2,6 +2,7 @@ from datetime import date
import functools
from django import http
from django.conf import settings
from django.shortcuts import redirect, get_object_or_404
import jingo
@ -111,14 +112,17 @@ def _queue(request, TableObj, tab):
'queue_counts': queue_counts})
def _queue_counts():
moderated = Review.objects.filter(reviewflag__isnull=False, editorreview=1)
return {'pending': ViewPendingQueue.objects.count(),
'nominated': ViewFullReviewQueue.objects.count(),
'prelim': ViewPreliminaryQueue.objects.count(),
'moderated': moderated.count()}
def _queue_counts(type=None):
counts = {'pending': ViewPendingQueue.objects.count,
'nominated': ViewFullReviewQueue.objects.count,
'prelim': ViewPreliminaryQueue.objects.count,
'moderated': Review.objects.filter(reviewflag__isnull=False,
editorreview=1).count}
if type:
return counts[type]()
for k, v in counts.items():
counts[k] = v()
return counts
@editor_required
def queue(request):
@ -177,7 +181,8 @@ def review(request, version_id):
version = get_object_or_404(Version, pk=version_id)
addon = version.addon
if addon.authors.filter(user=request.user).exists():
if (not settings.SELF_REVIEW_ALLOWED and
addon.authors.filter(user=request.user).exists()):
amo.messages.warning(request, _('Self-reviews are not allowed.'))
return redirect(reverse('editors.queue'))
@ -192,7 +197,7 @@ def review(request, version_id):
paging = {}
if num:
num = int(num)
total = _queue_counts().get(queue_type)
total = _queue_counts(queue_type)
paging = {'current': num, 'total': total,
'prev': num > 1, 'next': num < total,
'prev_url': '%s?num=%s' % (redirect_url, num - 1),

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

@ -800,3 +800,4 @@ DEFAULT_SUGGESTED_CONTRIBUTION = 5
PS_BIN = '/bin/ps'
BLOCKLIST_COOKIE = 'BLOCKLIST_v1'
SELF_REVIEW_ALLOWED = False