Revert "Return the created addon and version from Addon.from_upload, and use the return value where appropriate."
This reverts commit 180934d1f8
.
This commit is contained in:
Родитель
180934d1f8
Коммит
12ff4e4e6c
|
@ -442,10 +442,10 @@ class Addon(amo.models.OnChangeMixin, amo.models.ModelBase):
|
|||
addon.manifest_url = upload.name
|
||||
addon.app_domain = addon.domain_from_url(addon.manifest_url)
|
||||
addon.save()
|
||||
version = Version.from_upload(upload, addon, platforms)
|
||||
Version.from_upload(upload, addon, platforms)
|
||||
amo.log(amo.LOG.CREATE_ADDON, addon)
|
||||
log.debug('New addon %r from %r' % (addon, upload))
|
||||
return addon, version
|
||||
return addon
|
||||
|
||||
def flush_urls(self):
|
||||
urls = ['*/addon/%s/' % self.slug, # Doesn't take care of api
|
||||
|
|
|
@ -1591,7 +1591,7 @@ class TestAddonFromUpload(UploadTest):
|
|||
|
||||
def test_xpi_attributes(self):
|
||||
addon = Addon.from_upload(self.get_upload('extension.xpi'),
|
||||
[self.platform])[0]
|
||||
[self.platform])
|
||||
eq_(addon.name, 'xpi name')
|
||||
eq_(addon.guid, 'guid@xpi')
|
||||
eq_(addon.type, amo.ADDON_EXTENSION)
|
||||
|
@ -1603,27 +1603,27 @@ class TestAddonFromUpload(UploadTest):
|
|||
|
||||
def test_manifest_url(self):
|
||||
upload = self.get_upload(abspath=self.manifest('mozball.webapp'))
|
||||
addon = Addon.from_upload(upload, [self.platform])[0]
|
||||
addon = Addon.from_upload(upload, [self.platform])
|
||||
assert addon.is_webapp()
|
||||
eq_(addon.manifest_url, upload.name)
|
||||
|
||||
def test_app_domain(self):
|
||||
upload = self.get_upload(abspath=self.manifest('mozball.webapp'))
|
||||
upload.name = 'http://mozilla.com/my/rad/app.webapp' # manifest URL
|
||||
addon = Addon.from_upload(upload, [self.platform])[0]
|
||||
addon = Addon.from_upload(upload, [self.platform])
|
||||
eq_(addon.app_domain, 'http://mozilla.com')
|
||||
|
||||
def test_non_english_app(self):
|
||||
upload = self.get_upload(abspath=self.manifest('non-english.webapp'))
|
||||
upload.name = 'http://mozilla.com/my/rad/app.webapp' # manifest URL
|
||||
addon = Addon.from_upload(upload, [self.platform])[0]
|
||||
addon = Addon.from_upload(upload, [self.platform])
|
||||
eq_(addon.default_locale, 'it')
|
||||
eq_(unicode(addon.name), 'ItalianMozBall')
|
||||
eq_(addon.name.locale, 'it')
|
||||
|
||||
def test_xpi_version(self):
|
||||
addon = Addon.from_upload(self.get_upload('extension.xpi'),
|
||||
[self.platform])[0]
|
||||
[self.platform])
|
||||
v = addon.versions.get()
|
||||
eq_(v.version, '0.1')
|
||||
eq_(v.files.get().platform_id, self.platform.id)
|
||||
|
@ -1633,14 +1633,14 @@ class TestAddonFromUpload(UploadTest):
|
|||
platforms = [Platform.objects.get(pk=amo.PLATFORM_LINUX.id),
|
||||
Platform.objects.get(pk=amo.PLATFORM_MAC.id)]
|
||||
addon = Addon.from_upload(self.get_upload('extension.xpi'),
|
||||
platforms)[0]
|
||||
platforms)
|
||||
v = addon.versions.get()
|
||||
eq_(sorted([f.platform.id for f in v.all_files]),
|
||||
sorted([p.id for p in platforms]))
|
||||
|
||||
def test_search_attributes(self):
|
||||
addon = Addon.from_upload(self.get_upload('search.xml'),
|
||||
[self.platform])[0]
|
||||
[self.platform])
|
||||
eq_(addon.name, 'search tool')
|
||||
eq_(addon.guid, None)
|
||||
eq_(addon.type, amo.ADDON_SEARCH)
|
||||
|
@ -1652,7 +1652,7 @@ class TestAddonFromUpload(UploadTest):
|
|||
|
||||
def test_search_version(self):
|
||||
addon = Addon.from_upload(self.get_upload('search.xml'),
|
||||
[self.platform])[0]
|
||||
[self.platform])
|
||||
v = addon.versions.get()
|
||||
eq_(v.version, datetime.now().strftime('%Y%m%d'))
|
||||
eq_(v.files.get().platform_id, amo.PLATFORM_ALL.id)
|
||||
|
@ -1660,18 +1660,18 @@ class TestAddonFromUpload(UploadTest):
|
|||
|
||||
def test_no_homepage(self):
|
||||
addon = Addon.from_upload(self.get_upload('extension-no-homepage.xpi'),
|
||||
[self.platform])[0]
|
||||
[self.platform])
|
||||
eq_(addon.homepage, None)
|
||||
|
||||
def test_default_locale(self):
|
||||
# Make sure default_locale follows the active translation.
|
||||
addon = Addon.from_upload(self.get_upload('search.xml'),
|
||||
[self.platform])[0]
|
||||
[self.platform])
|
||||
eq_(addon.default_locale, 'en-US')
|
||||
|
||||
translation.activate('es')
|
||||
addon = Addon.from_upload(self.get_upload('search.xml'),
|
||||
[self.platform])[0]
|
||||
[self.platform])
|
||||
eq_(addon.default_locale, 'es')
|
||||
|
||||
def test_webapp_default_locale_override(self):
|
||||
|
@ -1682,7 +1682,7 @@ class TestAddonFromUpload(UploadTest):
|
|||
tmp.write(json.dumps(mf))
|
||||
tmp.flush()
|
||||
upload = self.get_upload(abspath=tmp.name)
|
||||
addon = Addon.from_upload(upload, [self.platform])[0]
|
||||
addon = Addon.from_upload(upload, [self.platform])
|
||||
eq_(addon.default_locale, 'es')
|
||||
|
||||
def test_webapp_default_locale_unsupported(self):
|
||||
|
@ -1693,14 +1693,14 @@ class TestAddonFromUpload(UploadTest):
|
|||
tmp.write(json.dumps(mf))
|
||||
tmp.flush()
|
||||
upload = self.get_upload(abspath=tmp.name)
|
||||
addon = Addon.from_upload(upload, [self.platform])[0]
|
||||
addon = Addon.from_upload(upload, [self.platform])
|
||||
eq_(addon.default_locale, 'en-US')
|
||||
|
||||
def test_browsing_locale_does_not_override(self):
|
||||
translation.activate('gb')
|
||||
# Upload app with en-US as default.
|
||||
upload = self.get_upload(abspath=self.manifest('mozball.webapp'))
|
||||
addon = Addon.from_upload(upload, [self.platform])[0]
|
||||
addon = Addon.from_upload(upload, [self.platform])
|
||||
eq_(addon.default_locale, 'en-US') # not gb
|
||||
|
||||
@raises(forms.ValidationError)
|
||||
|
|
|
@ -200,7 +200,7 @@ class AppsHandler(AddonsHandler):
|
|||
|
||||
# Fetch the addon, the icon and set the user.
|
||||
addon = Addon.from_upload(upload,
|
||||
[Platform.objects.get(id=amo.PLATFORM_ALL.id)])[0]
|
||||
[Platform.objects.get(id=amo.PLATFORM_ALL.id)])
|
||||
if addon.has_icon_in_manifest():
|
||||
tasks.fetch_icon(addon)
|
||||
AddonUser(addon=addon, user=request.amo_user).save()
|
||||
|
|
|
@ -1579,12 +1579,12 @@ def submit_addon(request, step, webapp=False):
|
|||
p = (list(data.get('desktop_platforms', [])) +
|
||||
list(data.get('mobile_platforms', [])))
|
||||
|
||||
addon, version = Addon.from_upload(data['upload'], p)
|
||||
addon = Addon.from_upload(data['upload'], p)
|
||||
if webapp:
|
||||
tasks.fetch_icon.delay(addon)
|
||||
AddonUser(addon=addon, user=request.amo_user).save()
|
||||
SubmitStep.objects.create(addon=addon, step=3)
|
||||
check_validation_override(request, form, addon, version)
|
||||
check_validation_override(request, form, addon, addon.current_version)
|
||||
return redirect(_step_url(3, webapp), addon.slug)
|
||||
template = 'upload_webapp.html' if webapp else 'upload.html'
|
||||
is_admin = acl.action_allowed(request, 'ReviewerAdminTools', 'View')
|
||||
|
|
|
@ -441,8 +441,9 @@ def fetch_langpacks(path, **kw):
|
|||
'language pack' % (data['version'], xpi))
|
||||
continue
|
||||
|
||||
addon, version = Addon.from_upload(upload, PLATFORMS)
|
||||
addon = Addon.from_upload(upload, PLATFORMS)
|
||||
AddonUser(addon=addon, user=owner).save()
|
||||
version = addon.versions.no_cache()[0]
|
||||
|
||||
addon.status = amo.STATUS_PUBLIC
|
||||
if addon.default_locale.lower() == lang.lower():
|
||||
|
|
|
@ -129,7 +129,7 @@ class AppResource(MarketplaceResource):
|
|||
|
||||
# Create app, user and fetch the icon.
|
||||
bundle.obj = Addon.from_upload(form.obj, plats,
|
||||
is_packaged=form.is_packaged)[0]
|
||||
is_packaged=form.is_packaged)
|
||||
AddonUser(addon=bundle.obj, user=request.amo_user).save()
|
||||
|
||||
self._icons_and_images(bundle.obj)
|
||||
|
|
|
@ -89,7 +89,7 @@ def manifest(request):
|
|||
addon = Addon.from_upload(
|
||||
form.cleaned_data['upload'],
|
||||
[Platform.objects.get(id=amo.PLATFORM_ALL.id)],
|
||||
is_packaged=form.is_packaged())[0]
|
||||
is_packaged=form.is_packaged())
|
||||
|
||||
# Set the device type.
|
||||
for device in form.get_devices():
|
||||
|
|
Загрузка…
Ссылка в новой задаче