don't allow premium to become prelim. (bug 694131)

This commit is contained in:
Andy McKay 2011-10-17 14:55:24 -07:00
Родитель 0e626f93e9
Коммит 5f070f87a5
2 изменённых файлов: 30 добавлений и 6 удалений

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

@ -399,14 +399,16 @@ class ReviewHelper:
labels, details = self._review_actions()
actions = SortedDict()
if (self.review_type != 'preliminary'):
if self.review_type != 'preliminary':
actions['public'] = {'method': self.handler.process_public,
'minimal': False,
'label': _lazy('Push to public')}
actions['prelim'] = {'method': self.handler.process_preliminary,
'label': labels['prelim'],
'minimal': False}
if not self.addon.is_premium():
actions['prelim'] = {'method': self.handler.process_preliminary,
'label': labels['prelim'],
'minimal': False}
actions['reject'] = {'method': self.handler.process_sandbox,
'label': _lazy('Reject'),
'minimal': False}
@ -640,6 +642,9 @@ class ReviewAddon(ReviewBase):
def process_preliminary(self):
"""Set an addon to preliminary."""
if self.addon.is_premium():
raise AssertionError('Premium add-ons cannot become preliminary.')
changes = {'status': amo.STATUS_LITE}
if (self.addon.status in (amo.STATUS_PUBLIC,
amo.STATUS_LITE_AND_NOMINATED)):
@ -712,6 +717,9 @@ class ReviewFiles(ReviewBase):
def process_preliminary(self):
"""Set an addons files to preliminary."""
if self.addon.is_premium():
raise AssertionError('Premium add-ons cannot become preliminary.')
self.set_files(amo.STATUS_LITE, self.data['addon_files'],
copy_to_mirror=True)

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

@ -1,8 +1,6 @@
# -*- coding: utf8 -*-
import os
from datetime import datetime, timedelta
import shutil
import tempfile
from django.core import mail
from django.conf import settings
@ -329,6 +327,11 @@ class TestReviewHelper(amo.tests.TestCase):
eq_(self.get_action(amo.STATUS_PUBLIC, 'public')[-29:],
'to appear on the public side.')
def test_action_premium(self):
self.addon.update(premium_type=amo.ADDON_PREMIUM)
self.assertRaises(KeyError, self.get_action,
amo.STATUS_NOMINATED, 'prelim')
def test_set_files(self):
self.file.update(datestatuschanged=yesterday)
self.helper.set_data({'addon_files': self.version.files.all()})
@ -463,6 +466,16 @@ class TestReviewHelper(amo.tests.TestCase):
eq_(self.check_log_count(amo.LOG.APPROVE_VERSION.id), 1)
def to_preliminary_premium(self, statuses):
self.addon.update(premium_type=amo.ADDON_PREMIUM)
for status in helpers.NOMINATED_STATUSES:
self.setup_data(status)
self.assertRaises(AssertionError,
self.helper.handler.process_preliminary)
def test_nomination_to_preliminary_premium(self):
self.to_preliminary_premium(helpers.NOMINATED_STATUSES)
def test_nomination_to_preliminary(self):
for status in helpers.NOMINATED_STATUSES:
self.setup_data(status)
@ -536,6 +549,9 @@ class TestReviewHelper(amo.tests.TestCase):
self.assertRaises(AssertionError,
self.helper.handler.process_public)
def test_preliminary_to_preliminary_premium(self):
self.to_preliminary_premium(helpers.PRELIMINARY_STATUSES)
def test_preliminary_to_preliminary(self):
for status in helpers.PRELIMINARY_STATUSES:
self.setup_data(status)