Updated version check to support binary components (bug 703783)

This commit is contained in:
Rob Hudson 2011-11-28 12:24:51 -08:00
Родитель 67f1b000af
Коммит 7a9a4ef9b9
55 изменённых файлов: 52 добавлений и 87 удалений

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

@ -31,8 +31,7 @@ class AddonAdmin(admin.ModelAdmin):
('Truthiness', {
'fields': ('disabled_by_user', 'trusted', 'view_source',
'public_stats', 'prerelease', 'admin_review',
'site_specific', 'external_software', 'binary',
'dev_agreement'),
'site_specific', 'external_software', 'dev_agreement'),
}),
('Money', {
'fields': ('wants_contributions', 'paypal_id', 'suggested_amount',

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

@ -126,7 +126,6 @@
"trusted": false,
"total_contributions": "0.00",
"locale_disambiguation": null,
"binary": false,
"guid": "nobody@nowhere.com",
"weekly_downloads": 75,
"support_url": null,

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

@ -126,7 +126,6 @@
"trusted": false,
"total_contributions": "0.00",
"locale_disambiguation": null,
"binary": false,
"guid": "nobody1@nowhere.com",
"weekly_downloads": 75,
"support_url": null,

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

@ -59,7 +59,6 @@
"the_future": null,
"trusted": 0,
"locale_disambiguation": null,
"binary": 0,
"guid": null,
"weekly_downloads": 146,
"support_url": null,

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

@ -16,7 +16,6 @@
"the_future": null,
"trusted": 0,
"locale_disambiguation": "",
"binary": 0,
"guid": "{2b925cbe-58ce-4af4-a62b-4bdd210045ca}",
"weekly_downloads": 14,
"support_url": null,
@ -104,7 +103,6 @@
"the_future": null,
"trusted": 0,
"locale_disambiguation": "",
"binary": 0,
"guid": "{f20592f7-9db4-4ce1-b4b0-8c509a949949}",
"weekly_downloads": 0,
"support_url": null,
@ -157,7 +155,6 @@
"the_future": null,
"trusted": 1,
"locale_disambiguation": "",
"binary": 0,
"guid": "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}",
"weekly_downloads": 916,
"support_url": null,

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

@ -28,7 +28,6 @@
"the_future": null,
"trusted": 0,
"locale_disambiguation": null,
"binary": 0,
"guid": "1ce9c2c3-01d4-4946-b19d-3b8e8e9daac4",
"weekly_downloads": 7534,
"paypal_id": "",

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

@ -23,7 +23,6 @@
"the_future": null,
"trusted": 0,
"locale_disambiguation": null,
"binary": 0,
"guid": "{fd20d4e6-5589-47ab-b2a9-f266ea3e493b}",
"weekly_downloads": 0,
"support_url": null,

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

@ -25,7 +25,6 @@
"the_future": null,
"trusted": 0,
"locale_disambiguation": null,
"binary": 0,
"guid": "{835A3F80-DF39-11D9-A0B5-000D0B3AEB26}",
"weekly_downloads": 0,
"support_url": null,

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

@ -98,7 +98,6 @@
"the_future": null,
"trusted": 0,
"locale_disambiguation": null,
"binary": 0,
"guid": null,
"weekly_downloads": 0,
"support_url": null,

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

@ -46,7 +46,6 @@
"trusted": 1,
"average_rating": "3.98",
"locale_disambiguation": "",
"binary": 0,
"the_future": null,
"total_reviews": 1106,
"view_source": 0,
@ -99,7 +98,6 @@
"trusted": 1,
"average_rating": "3.98",
"locale_disambiguation": "",
"binary": 0,
"the_future": null,
"total_reviews": 1106,
"view_source": 0,
@ -151,7 +149,6 @@
"trusted": 1,
"average_rating": "3.98",
"locale_disambiguation": "",
"binary": 0,
"the_future": null,
"total_reviews": 1106,
"view_source": 0,

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

@ -17,7 +17,6 @@
"trusted": true,
"total_contributions": "0.00",
"locale_disambiguation": null,
"binary": false,
"guid": "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}",
"weekly_downloads": 0,
"support_url": 118320,

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

@ -424,8 +424,7 @@ class AddonFormTechnical(AddonFormBase):
class Meta:
model = Addon
fields = ('developer_comments', 'view_source', 'site_specific',
'external_software', 'binary', 'auto_repackage',
'public_stats')
'external_software', 'auto_repackage', 'public_stats')
class AddonForm(happyforms.ModelForm):
@ -444,9 +443,8 @@ class AddonForm(happyforms.ModelForm):
fields = ('name', 'homepage', 'default_locale', 'support_email',
'support_url', 'description', 'summary',
'developer_comments', 'eula', 'privacy_policy', 'the_reason',
'the_future', 'view_source', 'prerelease', 'binary',
'site_specific', 'get_satisfaction_company',
'get_satisfaction_product',)
'the_future', 'view_source', 'prerelease', 'site_specific',
'get_satisfaction_company', 'get_satisfaction_product',)
exclude = ('status', )

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

@ -206,8 +206,6 @@ class Addon(amo.models.OnChangeMixin, amo.models.ModelBase):
db_column='sitespecific')
external_software = models.BooleanField(default=False,
db_column='externalsoftware')
binary = models.BooleanField(default=False,
help_text="Does the add-on contain a binary?")
dev_agreement = models.BooleanField(default=False,
help_text="Has the dev agreement been signed?")
auto_repackage = models.BooleanField(default=True,
@ -563,6 +561,11 @@ class Addon(amo.models.OnChangeMixin, amo.models.ModelBase):
self.update_version()
return self._current_version
@amo.cached_property
def binary(self):
"""Returns if the current version has binary files."""
return self.current_version.files.filter(binary=True).exists()
@property
def backup_version(self):
"""Returns the backup version."""

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

@ -1174,6 +1174,12 @@ class TestAddonModels(amo.tests.TestCase):
names = [c.name for c in cats]
assert addon.get_category(amo.FIREFOX.id).name in names
def test_binary_property(self):
addon = Addon.objects.get(id=3615)
file = addon.current_version.files.all()[0]
file.update(binary=True)
eq_(addon.binary, True)
class TestAddonGetURLPath(amo.tests.TestCase):

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

@ -369,6 +369,7 @@ class TestDefaultToCompat(amo.tests.TestCase):
self.addon = Addon.objects.get(id=1865)
self.platform = None
self.version_int = 5000000200100
self.file = File.objects.get(pk=96878)
self.app = Application.objects.get(id=1)
self.version_1_0_2 = 66463
@ -416,25 +417,41 @@ class TestDefaultToCompat(amo.tests.TestCase):
def test_no_strict_and_strict(self):
# File has strict_compatibility off and compatMode is strict.
File.objects.get(pk=96878).update(strict_compatibility=False)
self.file.update(strict_compatibility=False)
version, file = self.get('', self.version_int,
self.app, self.platform, 'strict')
eq_(version, None)
def test_no_strict_and_normal(self):
# File has strict_compatibility off and compatMode is normal.
File.objects.get(pk=96878).update(strict_compatibility=False)
self.file.update(strict_compatibility=False)
version, file = self.get('', self.version_int,
self.app, self.platform, 'normal')
eq_(version, self.version_1_3_0)
def test_no_strict_and_ignore(self):
# File has strict_compatibility off and compatMode is ignore.
File.objects.get(pk=96878).update(strict_compatibility=False)
self.file.update(strict_compatibility=False)
version, file = self.get('', self.version_int,
self.app, self.platform, 'ignore')
eq_(version, self.version_1_3_0)
def test_no_strict_w_binary_and_normal(self):
# File has strict_compatibility off and has binary compoments,
# compatMode is normal.
self.file.update(strict_compatibility=False, binary=True)
version, file = self.get('', self.version_int,
self.app, self.platform, 'normal')
eq_(version, self.version_1_2_2)
def test_addon_removed_binary(self):
# Addon had binary components but removed them in the latest version.
File.objects.get(pk=96877).update(binary=True)
self.file.update(strict_compatibility=False)
version, file = self.get('', self.version_int,
self.app, self.platform, 'normal')
eq_(version, self.version_1_3_0)
class TestResponse(amo.tests.TestCase):
fixtures = ['base/addon_3615',

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

@ -98,7 +98,6 @@
"trusted": false,
"description": 309894,
"locale_disambiguation": null,
"binary": false,
"the_future": null,
"weekly_downloads": 51417,
"support_url": 309897,

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

@ -40,7 +40,6 @@
"guid": "{d9284e50-81fc-11da-a72b-0800200c9a66}",
"trusted": false,
"locale_disambiguation": null,
"binary": false,
"weekly_downloads": 53380,
"paypal_id": "affiliate-fr@yoono.com",
"average_rating": "4.24",

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

@ -184,7 +184,6 @@
"trusted": true,
"description": 15002,
"locale_disambiguation": null,
"binary": false,
"the_future": null,
"weekly_downloads": 13053,
"support_url": 149594,

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

@ -19,7 +19,6 @@
"trusted": false,
"description": null,
"locale_disambiguation": null,
"binary": false,
"the_future": null,
"weekly_downloads": 0,
"support_url": null,

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

@ -29,7 +29,6 @@
"guid": "{7c07e56e-b2f0-4932-bbe2-857a91b69f45}",
"trusted": false,
"locale_disambiguation": null,
"binary": false,
"the_future": null,
"weekly_downloads": 12,
"support_url": null,

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

@ -50,7 +50,6 @@
"guid": null,
"trusted": false,
"locale_disambiguation": null,
"binary": false,
"the_future": null,
"weekly_downloads": 412,
"support_url": null,

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

@ -108,7 +108,6 @@
"trusted": false,
"description": 38750,
"locale_disambiguation": null,
"binary": false,
"weekly_downloads": 13849,
"support_url": 130757,
"paypal_id": "cfinke+premier@gmail.com",

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

@ -47,7 +47,6 @@
"guid": "bettergcal@ginatrapani.org",
"trusted": false,
"description": 58812,
"binary": false,
"weekly_downloads": 580,
"paypal_id": "",
"average_rating": "3.43",

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

@ -27,7 +27,6 @@
"guid": "yslow@yahoo-inc.com",
"trusted": false,
"locale_disambiguation": null,
"binary": false,
"the_future": null,
"weekly_downloads": 12628,
"paypal_id": "",

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

@ -53,7 +53,6 @@
"trusted": true,
"description": null,
"locale_disambiguation": null,
"binary": false,
"the_future": null,
"weekly_downloads": 50000,
"paypal_id": "",

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

@ -35,7 +35,6 @@
"guid": "{e968fc70-8f95-4ab9-9e79-304de2a71ee1}",
"trusted": 1,
"locale_disambiguation": null,
"binary": 0,
"weekly_downloads": 36381,
"paypal_id": "paypal@chrispederick.com",
"average_rating": "4.06",

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

@ -46,7 +46,6 @@
"guid": "{4c197c8f-a50f-4b49-a2d2-ed922c95612f}",
"trusted": true,
"locale_disambiguation": null,
"binary": false,
"weekly_downloads": 657,
"paypal_id": "gmailsmime@seantek.com",
"average_rating": "3.83",

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

@ -28,7 +28,6 @@
"guid": "{22870005-adef-4c9d-ae36-d0e1f2f27e5a}",
"trusted": false,
"locale_disambiguation": null,
"binary": false,
"the_future": null,
"weekly_downloads": 5726,
"paypal_id": "",

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

@ -29,7 +29,6 @@
"guid": "{b1fad17a-3b98-c743-ed56-85c722d622d3}",
"trusted": false,
"locale_disambiguation": null,
"binary": false,
"the_future": null,
"weekly_downloads": 541,
"support_url": null,

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

@ -28,7 +28,6 @@
"guid": "smarterwiki@wikiatic.com",
"trusted": false,
"locale_disambiguation": null,
"binary": false,
"weekly_downloads": 80506,
"paypal_id": "yongqli@10gic.net",
"average_rating": "4.85",

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

@ -166,7 +166,6 @@
"guid": "personas@christopher.beard",
"trusted": false,
"description": 333180,
"binary": false,
"weekly_downloads": 227202,
"support_url": 333188,
"disabled_by_user": false,

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

@ -82,7 +82,6 @@
"guid": "toolbar@sape.ru",
"trusted": 0,
"locale_disambiguation": null,
"binary": 0,
"the_future": null,
"weekly_downloads": 1252,
"paypal_id": "",

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

@ -41,7 +41,6 @@
"view_source": 0,
"guid": null,
"trusted": 0,
"binary": 0,
"annoying": 0,
"weekly_downloads": 8381,
"paypal_id": "",
@ -166,7 +165,6 @@
"guid": "quickdrag@mozilla.ktechcomputing.com",
"trusted": 0,
"locale_disambiguation": null,
"binary": 0,
"the_future": null,
"weekly_downloads": 16683,
"paypal_id": "",
@ -213,7 +211,6 @@
"guid": "isreaditlater@ideashower.com",
"trusted": 1,
"locale_disambiguation": null,
"binary": 0,
"weekly_downloads": 41099,
"paypal_id": "acc@ideashower.com",
"average_rating": "4.46",
@ -258,7 +255,6 @@
"guid": "foxyproxy@eric.h.jung",
"trusted": 1,
"locale_disambiguation": null,
"binary": 0,
"weekly_downloads": 98872,
"paypal_id": "support@leahscape.com",
"average_rating": "4.22",
@ -304,7 +300,6 @@
"guid": "{D2A6A719-7CBC-4594-85FD-C36AD881424F}",
"trusted": 1,
"locale_disambiguation": null,
"binary": 0,
"the_future": null,
"weekly_downloads": 11066,
"paypal_id": "",
@ -474,7 +469,6 @@
"guid": "limon@mbd",
"trusted": 0,
"locale_disambiguation": null,
"binary": 0,
"the_future": null,
"weekly_downloads": 4,
"support_url": null,

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

@ -123,7 +123,6 @@
"the_future": null,
"trusted": 0,
"locale_disambiguation": null,
"binary": 0,
"guid": null,
"weekly_downloads": 0,
"support_url": null,

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

@ -56,7 +56,6 @@
"guid": "bettergmail2@ginatrapani.org",
"trusted": 0,
"locale_disambiguation": null,
"binary": 0,
"weekly_downloads": 7760,
"paypal_id": "",
"average_rating": "3.99",

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

@ -421,7 +421,7 @@ class TestAddon(BaseOAuth):
the_future='is gone',
view_source=1,
prerelease=1,
binary=1,
binary=False,
site_specific=1,
get_satisfaction_company='yermom',
get_satisfaction_product='yer face',

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

@ -15,7 +15,6 @@
"the_future": null,
"trusted": 0,
"locale_disambiguation": null,
"binary": 0,
"guid": "dragdictionary@odeson",
"weekly_downloads": 72,
"support_url": null,

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

@ -60,7 +60,6 @@
"average_daily_downloads": 732,
"trusted": 0,
"locale_disambiguation": "",
"binary": 0,
"guid": "el-GR@dictionaries.addons.mozilla.org",
"weekly_downloads": 1554,
"paypal_id": "",
@ -103,7 +102,6 @@
"average_daily_downloads": 15920,
"trusted": 0,
"locale_disambiguation": "",
"binary": 0,
"guid": "en-US@dictionaries.addons.mozilla.org",
"weekly_downloads": 19445,
"paypal_id": "",
@ -144,7 +142,6 @@
"average_daily_downloads": 51,
"trusted": 0,
"locale_disambiguation": "myspell",
"binary": 0,
"guid": "roa-ES-val@dictionaries.addons.mozilla.org",
"weekly_downloads": 166,
"paypal_id": "",
@ -187,7 +184,6 @@
"average_daily_downloads": 361,
"trusted": 0,
"locale_disambiguation": "",
"binary": 0,
"guid": "openmedspel@e-medtools.com",
"weekly_downloads": 12817,
"paypal_id": "",
@ -230,7 +226,6 @@
"average_daily_downloads": 43,
"trusted": 0,
"locale_disambiguation": "AVL",
"binary": 0,
"guid": "ca-valencia@dictionaries.addons.mozilla.org",
"weekly_downloads": 148,
"paypal_id": "",
@ -273,7 +268,6 @@
"average_daily_downloads": 19,
"trusted": 0,
"locale_disambiguation": "",
"binary": 0,
"guid": "langpack-roa-ES-val@softwarevalencia.com",
"weekly_downloads": 73,
"paypal_id": "",
@ -316,7 +310,6 @@
"average_daily_downloads": 9,
"trusted": 0,
"locale_disambiguation": "",
"binary": 0,
"guid": "langpack-roa-ES-val@thunderbird.mozilla.org",
"weekly_downloads": 27,
"paypal_id": "",
@ -359,7 +352,6 @@
"average_daily_downloads": 23,
"trusted": 0,
"locale_disambiguation": "AVL",
"binary": 0,
"guid": "langpack-ca-valencia@firefox.mozilla.org",
"weekly_downloads": 74,
"paypal_id": "",
@ -402,7 +394,6 @@
"average_daily_downloads": 12,
"trusted": 0,
"locale_disambiguation": "AVL",
"binary": 0,
"guid": "langpack-ca-valencia@thunderbird.mozilla.org",
"weekly_downloads": 29,
"paypal_id": "",
@ -446,7 +437,6 @@
"average_daily_downloads": 2,
"trusted": 0,
"locale_disambiguation": "",
"binary": 0,
"guid": "langpack-wa@firefox.mozilla.org",
"weekly_downloads": 5,
"paypal_id": "",

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

@ -93,7 +93,6 @@
"trusted": false,
"total_contributions": null,
"locale_disambiguation": null,
"binary": false,
"guid": "DesktopMobile5Kumar@smartware.com",
"weekly_downloads": 0,
"support_url": null,

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

@ -80,7 +80,6 @@
"trusted": false,
"total_contributions": null,
"locale_disambiguation": null,
"binary": false,
"guid": null,
"weekly_downloads": 0,
"support_url": null,

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

@ -80,7 +80,6 @@
"trusted": false,
"total_contributions": null,
"locale_disambiguation": null,
"binary": false,
"guid": null,
"weekly_downloads": 0,
"support_url": null,

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

@ -168,7 +168,7 @@ def flag_binary(ids, **kw):
.get('contains_binary_extension', False))
log.info('Setting binary for addon with id: %s to %s'
% (addon.pk, binary))
addon.update(binary=binary)
file.update(binary=binary)
except Exception, err:
log.error('Failed to run validation on addon id: %s, %s'
% (addon.pk, err))

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

@ -90,10 +90,8 @@
form.external_software if editable else addon.external_software,
editable) }}
{{ flags(_("This add-on contains binary components."),
form.binary if editable else addon.binary, editable) }}
{% if not editable %}
{% call empty_unless(addon.site_specific or addon.external_software or addon.binary) %}{% endcall %}
{% call empty_unless(addon.site_specific or addon.external_software) %}{% endcall %}
{% endif %}
</div>
</td>

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

@ -128,7 +128,6 @@ class TestFlagBinary(amo.tests.TestCase):
def setUp(self):
self.addon = Addon.objects.get(pk=3615)
self.addon.update(binary=False)
@mock.patch('devhub.tasks.run_validator')
def test_flag_binary(self, _mock):

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

@ -620,8 +620,7 @@ class TestEditBasic(TestEdit):
def test_text_none_when_no_flags(self):
addon = self.get_addon()
addon.update(external_software=False, site_specific=False,
binary=False)
addon.update(external_software=False, site_specific=False)
r = self.client.get(self.url)
doc = pq(r.content)
eq_(doc('#addon-flags').text(), 'None')
@ -1177,7 +1176,6 @@ class TestEditTechnical(TestEdit):
def test_technical_on(self):
# Turn everything on
data = dict(developer_comments='Test comment!',
binary='on',
external_software='on',
site_specific='on',
view_source='on')
@ -1197,14 +1195,12 @@ class TestEditTechnical(TestEdit):
r = self.client.post(self.technical_edit_url, self.formset(data))
addon = self.get_addon()
eq_(addon.binary, False)
eq_(addon.external_software, False)
eq_(addon.site_specific, False)
eq_(addon.view_source, False)
def test_technical_devcomment_notrequired(self):
data = dict(developer_comments='',
binary='on',
external_software='on',
site_specific='on',
view_source='on')

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

@ -52,7 +52,6 @@
"admin_review_type": 1,
"trusted": false,
"total_contributions": "0.00",
"binary": false,
"guid": "qlt@vik.josh",
"weekly_downloads": 0,
"support_url": 1277096,

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

@ -100,7 +100,7 @@ class ViewQueue(RawSQLModel):
('admin_review', 'addons.adminreview'),
('is_site_specific', 'addons.sitespecific'),
('external_software', 'addons.externalsoftware'),
('binary', 'addons.binary'),
('binary', 'files.binary'),
('premium_type', 'addons.premium_type'),
('_latest_version_ids', """GROUP_CONCAT(versions.id
ORDER BY versions.created DESC)"""),

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

@ -63,6 +63,7 @@ class File(amo.models.OnChangeMixin, amo.models.ModelBase):
# The XPI contains JS that calls require("chrome").
requires_chrome = models.BooleanField(default=False)
reviewed = models.DateTimeField(null=True)
binary = models.BooleanField(default=False)
class Meta(amo.models.ModelBase.Meta):
db_table = 'files'
@ -634,7 +635,7 @@ class FileValidation(amo.models.ModelBase):
new.valid = new.errors == 0
if ('metadata' in js and
js['metadata'].get('contains_binary_extension', False)):
file.version.addon.update(binary=True)
file.update(binary=True)
new.save()
return new

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

@ -541,6 +541,7 @@ class TestFileUpload(UploadTest):
plat = Platform.objects.get(pk=amo.PLATFORM_LINUX.id)
file_ = File.from_upload(upload, version, plat)
eq_(file_.requires_chrome, True)
eq_(file_.binary, True)
class TestFileFromUpload(UploadTest):

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

@ -173,7 +173,6 @@
"the_future": null,
"trusted": true,
"locale_disambiguation": null,
"binary": false,
"guid": "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}",
"weekly_downloads": 813599,
"support_url": null,

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

@ -31,7 +31,6 @@
"the_future": null,
"trusted": 0,
"locale_disambiguation": null,
"binary": 0,
"guid": "{9f08cb5a-76b1-4bcf-aff9-90e1a5d60b1e}",
"weekly_downloads": 16809,
"support_url": null,

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

@ -80,7 +80,6 @@
"guid": null,
"trusted": 0,
"locale_disambiguation": null,
"binary": 0,
"the_future": null,
"weekly_downloads": 42,
"paypal_id": "",

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

@ -21,7 +21,6 @@
"trusted": false,
"total_contributions": null,
"locale_disambiguation": null,
"binary": false,
"guid": null,
"weekly_downloads": 9999,
"support_url": null,

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

@ -0,0 +1,4 @@
ALTER TABLE `files` ADD COLUMN `binary` bool NOT NULL DEFAULT '0';
-- Update files.binary with current value of addons.binary.
UPDATE files, versions, addons SET files.binary=1 WHERE files.version_id=versions.id AND versions.addon_id=addons.id AND addons.binary=1;
-- Not dropping addons.binary in case remora is still using it.

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

@ -223,10 +223,11 @@ class Update(object):
pass # no further SQL modification required.
elif self.compat_mode == 'normal':
# normal checks the file's strict_compatibility flag
sql.append("""
AND (CASE WHEN files.strict_compatibility = 1 THEN
appmax.version_int >= %(version_int)s ELSE 1 END)
# When file has strict_compatibility enabled, or file has binary
# components, default to compatible is disabled.
sql.append("""AND (
CASE WHEN files.strict_compatibility = 1 OR files.binary = 1
THEN appmax.version_int >= %(version_int)s ELSE 1 END)
""")
else: # Not defined or 'strict'.