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(): if addon.has_icon_in_manifest():
tasks.fetch_icon(addon) tasks.fetch_icon(addon)
AddonUser(addon=addon, user=request.amo_user).save() AddonUser(addon=addon, user=request.amo_user).save()
addon.update(status=amo.STATUS_PENDING if addon.update(status=amo.WEBAPPS_UNREVIEWED_STATUS)
settings.WEBAPPS_RESTRICTED else amo.STATUS_PUBLIC)
else: else:
return _form_error(form) 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. # An add-on in one of these statuses can become premium.
PREMIUM_STATUSES = (STATUS_NULL,) + STATUS_UNDER_REVIEW 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: # Types of administrative review queues for an add-on:
ADMIN_REVIEW_FULL = 1 ADMIN_REVIEW_FULL = 1
ADMIN_REVIEW_PRELIM = 2 ADMIN_REVIEW_PRELIM = 2

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

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

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

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

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

@ -6,7 +6,6 @@ import sys
import time import time
import traceback import traceback
import uuid import uuid
import operator
from django import http from django import http
from django.core.files.storage import default_storage as storage 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 payments.models import InappConfig
from paypal.check import Check from paypal.check import Check
import paypal import paypal
from product_details import product_details
from search.views import BaseAjaxSearch from search.views import BaseAjaxSearch
from stats.models import Contribution from stats.models import Contribution
from translations.models import delete_translation 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 # Special handling for webapps, where this is jumping to the done step
if addon.is_webapp(): if addon.is_webapp():
addon.update(status=amo.STATUS_PENDING if addon.update(status=amo.WEBAPPS_UNREVIEWED_STATUS)
settings.WEBAPPS_RESTRICTED else amo.STATUS_PUBLIC)
SubmitStep.objects.filter(addon=addon).delete() SubmitStep.objects.filter(addon=addon).delete()
signals.submission_done.send(sender=addon) signals.submission_done.send(sender=addon)

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

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

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

@ -1,7 +1,6 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
import logging import logging
from django.conf import settings
from django.db.models import Count from django.db.models import Count
import cronjobs import cronjobs
@ -20,28 +19,14 @@ task_log = logging.getLogger('z.task')
@cronjobs.register @cronjobs.register
def release_webapps(): def release_webapps():
""" """Turn apps from PENDING to PUBLIC so they show up on the site."""
Turn webapps from PENDING to LITE so they show up on the site. flip_webapp_status(amo.WEBAPPS_UNREVIEWED_STATUS, amo.STATUS_PUBLIC)
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)
@cronjobs.register @cronjobs.register
def restrict_webapps(): def restrict_webapps():
""" """Turn apps from PUBLIC to PENDING so they don't show up on the site."""
Turn webapps from LITE to PENDING so they don't show up on the site. flip_webapp_status(amo.STATUS_PUBLIC, amo.WEBAPPS_UNREVIEWED_STATUS)
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)
def flip_webapp_status(from_, to): def flip_webapp_status(from_, to):

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

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

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

@ -71,17 +71,10 @@ class TestWebapp(test_utils.TestCase):
w = Webapp() w = Webapp()
eq_(w.status, amo.STATUS_NULL) eq_(w.status, amo.STATUS_NULL)
w.mark_done() w.mark_done()
eq_(w.status, amo.STATUS_PENDING) eq_(w.status, amo.WEBAPPS_UNREVIEWED_STATUS)
@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)
@mock.patch('webapps.models.Webapp.get_manifest_json') @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() webapp = Webapp()
get_manifest_json.return_value = {} get_manifest_json.return_value = {}
eq_(webapp.has_icon_in_manifest(), False) eq_(webapp.has_icon_in_manifest(), False)

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

@ -912,14 +912,16 @@ PREVIEW_FULL_PATH = (PREVIEWS_PATH + '/full/%s/%d.png')
STATIC_URL = SITE_URL STATIC_URL = SITE_URL
ADDON_ICONS_DEFAULT_URL = MEDIA_URL + '/img/addon-icons' ADDON_ICONS_DEFAULT_URL = MEDIA_URL + '/img/addon-icons'
ADDON_ICON_BASE_URL = MEDIA_URL + 'img/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 + PREVIEW_THUMBNAIL_URL = (STATIC_URL +
'/img/uploads/previews/thumbs/%s/%d.png?modified=%d') '/img/uploads/previews/thumbs/%s/%d.png?modified=%d')
PREVIEW_FULL_URL = (STATIC_URL + PREVIEW_FULL_URL = (STATIC_URL +
'/img/uploads/previews/full/%s/%d.png?modified=%d') '/img/uploads/previews/full/%s/%d.png?modified=%d')
USERPICS_URL = STATIC_URL + '/img/uploads/userpics/%s/%s/%s.png?modified=%d' USERPICS_URL = STATIC_URL + '/img/uploads/userpics/%s/%s/%s.png?modified=%d'
# paths for uploaded extensions # 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 + NEW_PERSONAS_IMAGE_URL = (STATIC_URL +
'/img/uploads/personas/%(id)d/%(file)s') '/img/uploads/personas/%(id)d/%(file)s')
PERSONAS_IMAGE_URL = ('http://www.getpersonas.com/static/' 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_USER = 5
LOGIN_RATELIMIT_ALL_USERS = '15/m' 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 # 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: # have to be altered to the right domain for each server, eg:
# https://receiptcheck.addons.mozilla.org/verify/ # https://receiptcheck.addons.mozilla.org/verify/

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

@ -1,9 +1,6 @@
from mock import patch
from nose.tools import eq_ from nose.tools import eq_
from pyquery import PyQuery as pq from pyquery import PyQuery as pq
from django.conf import settings
from addons.models import Addon from addons.models import Addon
import amo import amo
import amo.tests import amo.tests
@ -110,7 +107,6 @@ class TestPaypal(amo.tests.TestCase):
self.assertRedirects(res, reverse('submit.app.terms')) self.assertRedirects(res, reverse('submit.app.terms'))
@patch.object(settings, 'WEBAPPS_RESTRICTED', True)
class TestPaypalResponse(amo.tests.TestCase): class TestPaypalResponse(amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'webapps/337141-steamcube'] 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', res = self.client.post(self.url, {'country': 'bob',
'address_one': '123 bob st.'}) 'address_one': '123 bob st.'})
eq_(res.status_code, 302) 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): def test_not_paypal_updates(self):
self.webapp.update(status=amo.STATUS_PUBLIC, paypal_id='bob@dog.com') 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) eq_(doc('#version-list').length, 0)
def test_pending(self): def test_pending(self):
# If settings.WEBAPPS_RESTRICTED = True, apps begin life as pending.
self.webapp.update(status=amo.STATUS_PENDING) self.webapp.update(status=amo.STATUS_PENDING)
r = self.client.get(self.url) r = self.client.get(self.url)
eq_(r.status_code, 200) eq_(r.status_code, 200)
eq_(pq(r.content)('#version-status .status-none').length, 1) eq_(pq(r.content)('#version-status .status-none').length, 1)
def test_public(self): def test_public(self):
# If settings.WEBAPPS_RESTRICTED = False, apps begin life as public.
eq_(self.webapp.status, amo.STATUS_PUBLIC) eq_(self.webapp.status, amo.STATUS_PUBLIC)
r = self.client.get(self.url) r = self.client.get(self.url)
eq_(r.status_code, 200) eq_(r.status_code, 200)

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

@ -1,4 +1,3 @@
import datetime
import json import json
import os import os
@ -711,11 +710,11 @@ class TestPayments(TestSubmit):
eq_(self.get_webapp().status, expected_status) eq_(self.get_webapp().status, expected_status)
def test_valid_pending(self): def test_valid_pending(self):
self._test_valid(amo.STATUS_PENDING) res = self.client.post(self.get_url('payments'),
{'premium_type': amo.ADDON_FREE})
@mock.patch.object(settings, 'WEBAPPS_RESTRICTED', False) eq_(res.status_code, 302)
def test_valid_public(self): self.assertRedirects(res, self.get_url('done'))
self._test_valid(amo.STATUS_PUBLIC) eq_(self.get_webapp().status, amo.WEBAPPS_UNREVIEWED_STATUS)
def test_premium(self): def test_premium(self):
for type_ in [amo.ADDON_PREMIUM, amo.ADDON_PREMIUM_INAPP]: 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: # Reset these URLs to the defaults so your settings_local doesn't clobber them:
ADDON_ICONS_DEFAULT_URL = MEDIA_URL + '/img/addon-icons' ADDON_ICONS_DEFAULT_URL = MEDIA_URL + '/img/addon-icons'
ADDON_ICON_BASE_URL = MEDIA_URL + 'img/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 + PREVIEW_THUMBNAIL_URL = (STATIC_URL +
'/img/uploads/previews/thumbs/%s/%d.png?modified=%d') '/img/uploads/previews/thumbs/%s/%d.png?modified=%d')
PREVIEW_FULL_URL = (STATIC_URL + PREVIEW_FULL_URL = (STATIC_URL +
@ -71,5 +72,3 @@ APP_PREVIEW = False
# Overrides whatever storage you might have put in local settings. # Overrides whatever storage you might have put in local settings.
DEFAULT_FILE_STORAGE = 'amo.utils.LocalFileStorage' DEFAULT_FILE_STORAGE = 'amo.utils.LocalFileStorage'
WEBAPPS_RESTRICTED = True