Added `is_packaged` to files for packaged apps (bug 777964)
This commit is contained in:
Родитель
bc01253634
Коммит
59503d7e22
|
@ -72,9 +72,12 @@ class File(amo.models.OnChangeMixin, amo.models.ModelBase):
|
|||
# file, used for default to compatible.
|
||||
binary_components = models.BooleanField(default=False, db_index=True)
|
||||
|
||||
# Whether a webapp uses flash or not
|
||||
# Whether a webapp uses flash or not.
|
||||
uses_flash = models.BooleanField(default=False, db_index=True)
|
||||
|
||||
# Whether the app is packaged or not (aka hosted).
|
||||
is_packaged = models.BooleanField(default=False, db_index=True)
|
||||
|
||||
class Meta(amo.models.ModelBase.Meta):
|
||||
db_table = 'files'
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE `files` ADD COLUMN `is_packaged` bool NOT NULL DEFAULT 0;
|
||||
CREATE INDEX `files_is_packaged` ON `files` (`is_packaged`);
|
|
@ -380,6 +380,13 @@ class Webapp(Addon):
|
|||
"""
|
||||
return self.get_latest_file().uses_flash
|
||||
|
||||
@amo.cached_property
|
||||
def has_packaged_files(self):
|
||||
"""
|
||||
Whether this app has any versions that are a packaged app.
|
||||
"""
|
||||
return self.versions.filter(files__is_packaged=True).exists()
|
||||
|
||||
|
||||
# Pull all translated_fields from Addon over to Webapp.
|
||||
Webapp._meta.translated_fields = Addon._meta.translated_fields
|
||||
|
|
|
@ -12,7 +12,7 @@ import waffle
|
|||
from addons.models import (Addon, AddonCategory, AddonDeviceType, AddonPremium,
|
||||
BlacklistedSlug, Category, Preview)
|
||||
import amo
|
||||
from amo.tests import TestCase, WebappTestCase
|
||||
from amo.tests import app_factory, TestCase, WebappTestCase
|
||||
from constants.applications import DEVICE_TYPES
|
||||
from market.models import Price
|
||||
from files.models import File
|
||||
|
@ -250,6 +250,12 @@ class TestWebapp(TestCase):
|
|||
eq_(sorted(Webapp.objects.get(id=w2.id).get_regions()),
|
||||
sorted(w2_regions))
|
||||
|
||||
def test_has_packaged_files(self):
|
||||
app1 = app_factory()
|
||||
eq_(app1.has_packaged_files, False)
|
||||
app2 = app_factory(file_kw=dict(is_packaged=True))
|
||||
eq_(app2.has_packaged_files, True)
|
||||
|
||||
|
||||
class TestWebappVersion(amo.tests.TestCase):
|
||||
fixtures = ['base/platforms']
|
||||
|
@ -375,7 +381,8 @@ class TestTransformer(amo.tests.TestCase):
|
|||
assert transformer.called
|
||||
|
||||
def test_device_types(self):
|
||||
AddonDeviceType.objects.create(addon_id=337141, device_type=self.device)
|
||||
AddonDeviceType.objects.create(addon_id=337141,
|
||||
device_type=self.device)
|
||||
webapps = list(Webapp.objects.filter(id=337141))
|
||||
|
||||
with self.assertNumQueries(0):
|
||||
|
|
Загрузка…
Ссылка в новой задаче