remove WEBAPPS_RESTRICTED flag (bug 730500)

This commit is contained in:
Chris Van 2012-03-06 16:24:50 -08:00
Родитель aac86e2e3e
Коммит fdaf797967
14 изменённых файлов: 32 добавлений и 86 удалений

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

@ -204,8 +204,7 @@ class AppsHandler(AddonsHandler):
if addon.has_icon_in_manifest():
tasks.fetch_icon(addon)
AddonUser(addon=addon, user=request.amo_user).save()
addon.update(status=amo.STATUS_PENDING if
settings.WEBAPPS_RESTRICTED else amo.STATUS_PUBLIC)
addon.update(status=amo.WEBAPPS_UNREVIEWED_STATUS)
else:
return _form_error(form)

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

@ -57,6 +57,9 @@ MIRROR_STATUSES = (STATUS_PUBLIC, STATUS_BETA,
# An add-on in one of these statuses can become premium.
PREMIUM_STATUSES = (STATUS_NULL,) + STATUS_UNDER_REVIEW
# Newly submitted apps begin life at this status.
WEBAPPS_UNREVIEWED_STATUS = STATUS_PENDING
# Types of administrative review queues for an add-on:
ADMIN_REVIEW_FULL = 1
ADMIN_REVIEW_PRELIM = 2

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

@ -4,7 +4,6 @@ import os
import socket
from datetime import datetime, timedelta
from decimal import Decimal
from collections import namedtuple
from django.conf import settings
from django.core import mail
@ -33,8 +32,8 @@ from amo.tests import (formset, initial, close_to_now,
from amo.tests.test_helpers import get_image_path
from amo.urlresolvers import reverse
from addons import cron
from addons.models import (Addon, AddonCategory, AddonDeviceType, AddonUpsell,
AddonUser, Category, Charity, DeviceType)
from addons.models import (Addon, AddonCategory, AddonUpsell, AddonUser,
Category, Charity)
from addons.utils import ReverseNameLookup
from applications.models import Application, AppVersion
from browse.tests import test_listing_sort, test_default_sort
@ -2250,8 +2249,7 @@ class TestSubmitStep4(TestSubmitBase):
assert_raises(SubmitStep.DoesNotExist, self.get_step)
self.assertRedirects(r, reverse('devhub.submit_apps.5',
args=[self.get_addon().slug]))
eq_(self.get_addon().status, amo.STATUS_PENDING if
settings.WEBAPPS_RESTRICTED else amo.STATUS_PUBLIC)
eq_(self.get_addon().status, amo.WEBAPPS_UNREVIEWED_STATUS)
def formset_new_form(self, *args, **kw):
ctx = self.client.get(self.url).context

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

@ -380,14 +380,12 @@ class TestAppStatus(amo.tests.TestCase):
eq_(doc('#version-list').length, 0)
def test_pending(self):
# If settings.WEBAPPS_RESTRICTED = True, apps begin life as pending.
self.webapp.update(status=amo.STATUS_PENDING)
r = self.client.get(self.url)
eq_(r.status_code, 200)
eq_(pq(r.content)('#version-status .status-none').length, 1)
def test_public(self):
# If settings.WEBAPPS_RESTRICTED = False, apps begin life as public.
eq_(self.webapp.status, amo.STATUS_PUBLIC)
r = self.client.get(self.url)
eq_(r.status_code, 200)

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

@ -6,7 +6,6 @@ import sys
import time
import traceback
import uuid
import operator
from django import http
from django.core.files.storage import default_storage as storage
@ -51,7 +50,6 @@ from market.models import AddonPremium, Refund
from payments.models import InappConfig
from paypal.check import Check
import paypal
from product_details import product_details
from search.views import BaseAjaxSearch
from stats.models import Contribution
from translations.models import delete_translation
@ -1593,8 +1591,7 @@ def submit_media(request, addon_id, addon, step, webapp=False):
# Special handling for webapps, where this is jumping to the done step
if addon.is_webapp():
addon.update(status=amo.STATUS_PENDING if
settings.WEBAPPS_RESTRICTED else amo.STATUS_PUBLIC)
addon.update(status=amo.WEBAPPS_UNREVIEWED_STATUS)
SubmitStep.objects.filter(addon=addon).delete()
signals.submission_done.send(sender=addon)

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

@ -899,29 +899,17 @@ class TestAppQueue(EditorTest):
def setUp(self):
self.login_as_editor()
self.apps = [addon_factory(name='XXX', type=amo.ADDON_WEBAPP),
addon_factory(name='YYY', type=amo.ADDON_WEBAPP)]
self.apps = [addon_factory(name='XXX', type=amo.ADDON_WEBAPP,
status=amo.WEBAPPS_UNREVIEWED_STATUS),
addon_factory(name='YYY', type=amo.ADDON_WEBAPP,
status=amo.WEBAPPS_UNREVIEWED_STATUS)]
self.url = reverse('editors.queue_apps')
def review_url(self, app, num):
return urlparams(reverse('editors.app_review', args=[app.slug]),
num=num)
@patch.object(settings, 'WEBAPPS_RESTRICTED', False)
def test_results(self):
r = self.client.get(self.url)
eq_(r.status_code, 200)
links = pq(r.content)('#addon-queue tbody')('tr td:nth-of-type(2) a')
apps = Webapp.objects.pending().order_by('created')
expected = [
(unicode(apps[0].name), self.review_url(apps[0], '1')),
(unicode(apps[1].name), self.review_url(apps[1], '2')),
]
check_links(expected, links, verify=False)
@patch.object(settings, 'WEBAPPS_RESTRICTED', True)
def test_restricted_results(self):
Webapp.objects.update(status=amo.STATUS_PENDING)
r = self.client.get(self.url)
eq_(r.status_code, 200)
links = pq(r.content)('#addon-queue tbody')('tr td:nth-of-type(2) a')
@ -932,7 +920,6 @@ class TestAppQueue(EditorTest):
]
check_links(expected, links, verify=False)
@patch.object(settings, 'WEBAPPS_RESTRICTED', False)
@patch('waffle.flag_is_active')
def test_queue_count(self, flag):
flag.return_value = True
@ -940,14 +927,12 @@ class TestAppQueue(EditorTest):
eq_(r.status_code, 200)
eq_(pq(r.content)('.tabnav li a:eq(5)').text(), u'Apps (2)')
@patch.object(settings, 'WEBAPPS_RESTRICTED', False)
def test_sort(self):
r = self.client.get(self.url, {'sort': '-name'})
eq_(r.status_code, 200)
eq_(pq(r.content)('#addon-queue tbody tr').eq(0).attr('data-addon'),
str(self.apps[1].id))
@patch.object(settings, 'WEBAPPS_RESTRICTED', False)
def test_redirect_to_review(self):
r = self.client.get(self.url, {'num': 2})
self.assertRedirects(r, self.review_url(self.apps[1], num=2))

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

@ -1,7 +1,6 @@
from datetime import datetime, timedelta
import logging
from django.conf import settings
from django.db.models import Count
import cronjobs
@ -20,28 +19,14 @@ task_log = logging.getLogger('z.task')
@cronjobs.register
def release_webapps():
"""
Turn webapps from PENDING to LITE so they show up on the site.
This should be run when WEBAPPS_RESTRICTED is flipped.
"""
if settings.WEBAPPS_RESTRICTED:
print 'You should set `WEBAPPS_RESTRICTED = False` first.'
return
flip_webapp_status(amo.STATUS_PENDING, amo.STATUS_PUBLIC)
"""Turn apps from PENDING to PUBLIC so they show up on the site."""
flip_webapp_status(amo.WEBAPPS_UNREVIEWED_STATUS, amo.STATUS_PUBLIC)
@cronjobs.register
def restrict_webapps():
"""
Turn webapps from LITE to PENDING so they don't show up on the site.
This should be run if WEBAPPS_RESTRICTED gets rolled back.
"""
if not settings.WEBAPPS_RESTRICTED:
print 'You should set `WEBAPPS_RESTRICTED = True` first.'
return
flip_webapp_status(amo.STATUS_PUBLIC, amo.STATUS_PENDING)
"""Turn apps from PUBLIC to PENDING so they don't show up on the site."""
flip_webapp_status(amo.STATUS_PUBLIC, amo.WEBAPPS_UNREVIEWED_STATUS)
def flip_webapp_status(from_, to):

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

@ -64,9 +64,7 @@ class WebappManager(amo.models.ManagerBase):
# ** Reviewed -- PUBLIC
# ** Unreviewed -- LITE
# ** Rejected -- REJECTED
status = (amo.STATUS_PENDING if settings.WEBAPPS_RESTRICTED
else amo.STATUS_PUBLIC)
return self.filter(status=status)
return self.filter(status=amo.WEBAPPS_UNREVIEWED_STATUS)
# We use super(Addon, self) on purpose to override expectations in Addon that
@ -173,8 +171,7 @@ class Webapp(Addon):
def mark_done(self):
"""When the submission process is done, update status accordingly."""
self.update(status=amo.STATUS_PENDING if settings.WEBAPPS_RESTRICTED
else amo.STATUS_PUBLIC)
self.update(status=amo.WEBAPPS_UNREVIEWED_STATUS)
# Pull all translated_fields from Addon over to Webapp.

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

@ -71,17 +71,10 @@ class TestWebapp(test_utils.TestCase):
w = Webapp()
eq_(w.status, amo.STATUS_NULL)
w.mark_done()
eq_(w.status, amo.STATUS_PENDING)
@mock.patch.object(settings, 'WEBAPPS_RESTRICTED', False)
def test_mark_done_public(self):
w = Webapp()
eq_(w.status, amo.STATUS_NULL)
w.mark_done()
eq_(w.status, amo.STATUS_PUBLIC)
eq_(w.status, amo.WEBAPPS_UNREVIEWED_STATUS)
@mock.patch('webapps.models.Webapp.get_manifest_json')
def test_has_icon_in_manifest(self, get_manifest_json):
def test_no_icon_in_manifest(self, get_manifest_json):
webapp = Webapp()
get_manifest_json.return_value = {}
eq_(webapp.has_icon_in_manifest(), False)

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

@ -912,14 +912,16 @@ PREVIEW_FULL_PATH = (PREVIEWS_PATH + '/full/%s/%d.png')
STATIC_URL = SITE_URL
ADDON_ICONS_DEFAULT_URL = MEDIA_URL + '/img/addon-icons'
ADDON_ICON_BASE_URL = MEDIA_URL + 'img/icons/'
ADDON_ICON_URL = STATIC_URL + '/img/uploads/addon_icons/%s/%s-%s.png?modified=%s'
ADDON_ICON_URL = (STATIC_URL +
'/img/uploads/addon_icons/%s/%s-%s.png?modified=%s')
PREVIEW_THUMBNAIL_URL = (STATIC_URL +
'/img/uploads/previews/thumbs/%s/%d.png?modified=%d')
PREVIEW_FULL_URL = (STATIC_URL +
'/img/uploads/previews/full/%s/%d.png?modified=%d')
USERPICS_URL = STATIC_URL + '/img/uploads/userpics/%s/%s/%s.png?modified=%d'
# paths for uploaded extensions
COLLECTION_ICON_URL = STATIC_URL + '/img/uploads/collection_icons/%s/%s.png?m=%s'
COLLECTION_ICON_URL = (STATIC_URL +
'/img/uploads/collection_icons/%s/%s.png?m=%s')
NEW_PERSONAS_IMAGE_URL = (STATIC_URL +
'/img/uploads/personas/%(id)d/%(file)s')
PERSONAS_IMAGE_URL = ('http://www.getpersonas.com/static/'
@ -1320,9 +1322,6 @@ DEVELOPER_BLOG_URL = 'http://blog.mozilla.com/addons/feed/'
LOGIN_RATELIMIT_USER = 5
LOGIN_RATELIMIT_ALL_USERS = '15/m'
# If this is true all new webapps go into an approval queue. If it's false then
# they go public immediately.
WEBAPPS_RESTRICTED = True
# The verification URL, the addon id will be appended to this. This will
# have to be altered to the right domain for each server, eg:
# https://receiptcheck.addons.mozilla.org/verify/

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

@ -1,9 +1,6 @@
from mock import patch
from nose.tools import eq_
from pyquery import PyQuery as pq
from django.conf import settings
from addons.models import Addon
import amo
import amo.tests
@ -110,7 +107,6 @@ class TestPaypal(amo.tests.TestCase):
self.assertRedirects(res, reverse('submit.app.terms'))
@patch.object(settings, 'WEBAPPS_RESTRICTED', True)
class TestPaypalResponse(amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'webapps/337141-steamcube']
@ -129,7 +125,7 @@ class TestPaypalResponse(amo.tests.TestCase):
res = self.client.post(self.url, {'country': 'bob',
'address_one': '123 bob st.'})
eq_(res.status_code, 302)
eq_(self.get_webapp().status, amo.STATUS_PENDING)
eq_(self.get_webapp().status, amo.WEBAPPS_UNREVIEWED_STATUS)
def test_not_paypal_updates(self):
self.webapp.update(status=amo.STATUS_PUBLIC, paypal_id='bob@dog.com')

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

@ -54,14 +54,12 @@ class TestAppStatus(amo.tests.TestCase):
eq_(doc('#version-list').length, 0)
def test_pending(self):
# If settings.WEBAPPS_RESTRICTED = True, apps begin life as pending.
self.webapp.update(status=amo.STATUS_PENDING)
r = self.client.get(self.url)
eq_(r.status_code, 200)
eq_(pq(r.content)('#version-status .status-none').length, 1)
def test_public(self):
# If settings.WEBAPPS_RESTRICTED = False, apps begin life as public.
eq_(self.webapp.status, amo.STATUS_PUBLIC)
r = self.client.get(self.url)
eq_(r.status_code, 200)

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

@ -1,4 +1,3 @@
import datetime
import json
import os
@ -711,11 +710,11 @@ class TestPayments(TestSubmit):
eq_(self.get_webapp().status, expected_status)
def test_valid_pending(self):
self._test_valid(amo.STATUS_PENDING)
@mock.patch.object(settings, 'WEBAPPS_RESTRICTED', False)
def test_valid_public(self):
self._test_valid(amo.STATUS_PUBLIC)
res = self.client.post(self.get_url('payments'),
{'premium_type': amo.ADDON_FREE})
eq_(res.status_code, 302)
self.assertRedirects(res, self.get_url('done'))
eq_(self.get_webapp().status, amo.WEBAPPS_UNREVIEWED_STATUS)
def test_premium(self):
for type_ in [amo.ADDON_PREMIUM, amo.ADDON_PREMIUM_INAPP]:

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

@ -57,7 +57,8 @@ MEDIA_URL = '/media/'
# Reset these URLs to the defaults so your settings_local doesn't clobber them:
ADDON_ICONS_DEFAULT_URL = MEDIA_URL + '/img/addon-icons'
ADDON_ICON_BASE_URL = MEDIA_URL + 'img/icons/'
ADDON_ICON_URL = STATIC_URL + '/img/uploads/addon_icons/%s/%s-%s.png?modified=%s'
ADDON_ICON_URL = (STATIC_URL +
'/img/uploads/addon_icons/%s/%s-%s.png?modified=%s')
PREVIEW_THUMBNAIL_URL = (STATIC_URL +
'/img/uploads/previews/thumbs/%s/%d.png?modified=%d')
PREVIEW_FULL_URL = (STATIC_URL +
@ -71,5 +72,3 @@ APP_PREVIEW = False
# Overrides whatever storage you might have put in local settings.
DEFAULT_FILE_STORAGE = 'amo.utils.LocalFileStorage'
WEBAPPS_RESTRICTED = True