Fixed mishandling of file status when app is publicized (bug 801678)

This commit is contained in:
Rob Hudson 2012-10-15 12:59:23 -07:00
Родитель 555d14012d
Коммит 0c015fe745
2 изменённых файлов: 40 добавлений и 30 удалений

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

@ -106,13 +106,13 @@ class TestPayPalJS(amo.tests.TestCase):
self.create_switch('enabled-paypal', active=False)
resp = self.client.get(self.url)
assert not settings.PAYPAL_JS_URL in resp.content, (
'When paypal is disabled, its JS lib should not load')
'When paypal is disabled, its JS lib should not load')
def test_load_paypal_js(self):
self.create_switch('enabled-paypal')
resp = self.client.get(self.url)
assert settings.PAYPAL_JS_URL in resp.content, (
'When paypal is enabled, its JS lib should load')
'When paypal is enabled, its JS lib should load')
class TestAppBreadcrumbs(AppHubTest):
@ -196,7 +196,7 @@ class TestAppDashboard(AppHubTest):
app = self.get_app()
self.make_mine()
app.update(is_packaged=True)
next_version = Version.objects.create(addon=app, version='1.24')
Version.objects.create(addon=app, version='1.24')
doc = pq(self.client.get(self.url).content)
eq_(doc('.item[data-addonid=%s] .item-latest-version' % app.id
).text(),
@ -216,7 +216,7 @@ class TestAppDashboard(AppHubTest):
]
amo.tests.check_links(expected, doc('a.action-link'))
amo.tests.check_links([('View Statistics', app.get_stats_url())],
doc('a.stats-link'), verify=False)
doc('a.stats-link'), verify=False)
def test_action_links_packaged(self):
self.create_switch('app-stats')
@ -233,7 +233,7 @@ class TestAppDashboard(AppHubTest):
]
amo.tests.check_links(expected, doc('a.action-link'))
amo.tests.check_links([('View Statistics', app.get_stats_url())],
doc('a.stats-link'), verify=False)
doc('a.stats-link'), verify=False)
def test_disabled_payments_action_links(self):
self.create_switch('app-stats')
@ -482,7 +482,7 @@ class MarketplaceMixin(object):
self.addon = Addon.objects.get(id=337141)
self.addon.update(status=amo.STATUS_NOMINATED,
highest_status=amo.STATUS_NOMINATED)
highest_status=amo.STATUS_NOMINATED)
self.url = self.addon.get_dev_url('payments')
assert self.client.login(username='steamcube@mozilla.com',
@ -518,7 +518,7 @@ class MarketplaceMixin(object):
# that the account exists on paypal.
#
@mock.patch('mkt.developers.forms.PremiumForm.clean',
new=lambda x: x.cleaned_data)
new=lambda x: x.cleaned_data)
class TestMarketplace(MarketplaceMixin, amo.tests.TestCase):
fixtures = ['base/users', 'webapps/337141-steamcube', 'market/prices']
@ -568,8 +568,8 @@ class TestMarketplace(MarketplaceMixin, amo.tests.TestCase):
data=self.get_data(currencies=['EUR', 'LOL']))
eq_(res.status_code, 200)
self.assertFormError(res, 'form', 'currencies',
[u'Select a valid choice. '
'LOL is not one of the available choices.'])
[u'Select a valid choice. '
'LOL is not one of the available choices.'])
def test_set_upsell(self):
self.setup_premium()
@ -636,7 +636,7 @@ class TestMarketplace(MarketplaceMixin, amo.tests.TestCase):
eq_(self.addon.premium.paypal_permissions_token, '')
url = self.addon.get_dev_url('acquire_refund_permission')
self.client.get(urlparams(url, request_token='foo',
verification_code='bar'))
verification_code='bar'))
self.addon = Addon.objects.get(pk=self.addon.pk)
eq_(self.addon.premium.paypal_permissions_token.lower(), 'foo')
@ -648,7 +648,7 @@ class TestMarketplace(MarketplaceMixin, amo.tests.TestCase):
self.setup_premium()
url = self.addon.get_dev_url('acquire_refund_permission')
self.client.get(urlparams(url, request_token='foo',
verification_code='bar'))
verification_code='bar'))
self.addon = Addon.objects.get(pk=self.addon.pk)
eq_(self.addon.premium.paypal_permissions_token.lower(), 'foo')
@ -922,8 +922,8 @@ class TestIssueRefund(amo.tests.TestCase):
everyone=True)
client.post_refund.return_value = {'response': [{
'refundStatus': 'ALREADY_REVERSED_OR_REFUNDED',
'receiver.email': self.user.email}]}
'refundStatus': 'ALREADY_REVERSED_OR_REFUNDED',
'receiver.email': self.user.email}]}
c = self.make_purchase()
r = self.client.post(self.url, {'transaction_id': c.transaction_id,
'issue': '1'})
@ -983,7 +983,8 @@ class TestRefunds(amo.tests.TestCase):
for status in amo.REFUND_STATUSES.keys():
for x in xrange(status + 2):
c = Contribution.objects.create(addon=self.webapp,
user=self.user, type=amo.CONTRIB_PURCHASE)
user=self.user,
type=amo.CONTRIB_PURCHASE)
r = Refund.objects.create(contribution=c, status=status,
requested=days_ago(x))
self.expected.setdefault(status, []).append(r)
@ -1129,6 +1130,8 @@ class TestPublicise(amo.tests.TestCase):
def setUp(self):
self.webapp = self.get_webapp()
self.webapp.update(status=amo.STATUS_PUBLIC_WAITING)
self.file = self.webapp.versions.latest().all_files[0]
self.file.update(status=amo.STATUS_PUBLIC_WAITING)
self.publicise_url = self.webapp.get_dev_url('publicise')
self.status_url = self.webapp.get_dev_url('versions')
assert self.client.login(username='steamcube@mozilla.com',
@ -1147,6 +1150,8 @@ class TestPublicise(amo.tests.TestCase):
res = self.client.post(self.publicise_url)
eq_(res.status_code, 302)
eq_(self.get_webapp().status, amo.STATUS_PUBLIC)
eq_(self.get_webapp().versions.latest().all_files[0].status,
amo.STATUS_PUBLIC)
def test_status(self):
res = self.client.get(self.status_url)

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

@ -133,14 +133,15 @@ def dashboard(request, webapp=False):
@dev_required(webapp=True)
def edit(request, addon_id, addon, webapp=False):
data = {
'page': 'edit',
'addon': addon,
'webapp': webapp,
'valid_slug': addon.app_slug,
'image_sizes': APP_IMAGE_SIZES,
'tags': addon.tags.not_blacklisted().values_list('tag_text', flat=True),
'previews': addon.get_previews(),
'device_type_form': DeviceTypeForm(request.POST or None, addon=addon),
'page': 'edit',
'addon': addon,
'webapp': webapp,
'valid_slug': addon.app_slug,
'image_sizes': APP_IMAGE_SIZES,
'tags': addon.tags.not_blacklisted().values_list('tag_text',
flat=True),
'previews': addon.get_previews(),
'device_type_form': DeviceTypeForm(request.POST or None, addon=addon),
}
if acl.action_allowed(request, 'Apps', 'Configure'):
data['admin_settings_form'] = forms.AdminSettingsForm(instance=addon)
@ -191,6 +192,9 @@ def disable(request, addon_id, addon):
def publicise(request, addon_id, addon):
if addon.status == amo.STATUS_PUBLIC_WAITING:
addon.update(status=amo.STATUS_PUBLIC)
File.objects.filter(
version__addon=addon, status=amo.STATUS_PUBLIC_WAITING).update(
status=amo.STATUS_PUBLIC)
amo.log(amo.LOG.CHANGE_STATUS, addon.get_status_display(), addon)
# Call update_version, so various other bits of data update.
addon.update_version()
@ -471,7 +475,7 @@ def paypal_setup_confirm(request, addon_id, addon, webapp, source='paypal'):
if waffle.flag_is_active(request, 'solitude-payments'):
obj = client.create_seller_paypal(addon)
client.patch_seller_paypal(pk=obj['resource_pk'],
data={'paypal_id': addon.paypal_id})
data={'paypal_id': addon.paypal_id})
if waffle.flag_is_active(request, 'solitude-payments'):
# TODO(solitude): when the migration of data is completed, we
@ -564,7 +568,7 @@ def bluevia_callback(request, addon_id, addon, webapp):
status = request.POST.get('status')
if status in ['registered', 'loggedin']:
bluevia = BlueViaConfig.objects.create(user=request.amo_user,
developer_id=developer_id)
developer_id=developer_id)
try:
(AddonBlueViaConfig.objects.get(addon=addon)
.update(bluevia_config=bluevia))
@ -718,8 +722,8 @@ def issue_refund(request, addon_id, addon, webapp=False):
if 'issue' in request.POST:
if waffle.flag_is_active(request, 'solitude-payments'):
try:
response = client.post_refund(data={'uuid':
contribution.transaction_id})
response = client.post_refund(
data={'uuid': contribution.transaction_id})
except client.Error, e:
contribution.record_failed_refund(e)
paypal_log.error('Refund failed for: %s' % txn_id,
@ -756,8 +760,9 @@ def issue_refund(request, addon_id, addon, webapp=False):
contribution.paykey,
res['receiver.email']))
messages.error(request,
_("A refund can't be issued at this time. We've "
"notified an admin; please try again later."))
_("A refund can't be issued at this time. "
"We've notified an admin; please try "
"again later."))
return redirect(addon.get_dev_url('refunds'))
contribution.mail_approved()
@ -972,7 +977,7 @@ def file_validation(request, addon_id, addon, file_id):
@dev_required(allow_editors=True)
def json_file_validation(request, addon_id, addon, file_id):
file = get_object_or_404(File, id=file_id)
if not file.has_been_validated == True:
if not file.has_been_validated:
if request.method != 'POST':
return http.HttpResponseNotAllowed(['POST'])
@ -1013,7 +1018,7 @@ def json_upload_detail(request, upload, addon_slug=None):
def upload_validation_context(request, upload, addon_slug=None, addon=None,
url=None):
url=None):
if addon_slug and not addon:
addon = get_object_or_404(Addon, slug=addon_slug)
if not settings.VALIDATE_ADDONS: