Make sure unsupported applications are not taken into account on addon upload (bug 1006654)
This commit is contained in:
Родитель
8bd75674e8
Коммит
d71992a16f
|
@ -20,8 +20,8 @@ class Command(BaseCommand):
|
|||
|
||||
def handle(self, *args, **kw):
|
||||
apps = {}
|
||||
for id, guid in (Application.objects.values_list('id', 'guid')
|
||||
.exclude(supported=0)):
|
||||
for id, guid in (Application.objects
|
||||
.supported().values_list('id', 'guid')):
|
||||
apps[id] = dict(guid=guid, versions=[],
|
||||
name=amo.APPS_ALL[id].short)
|
||||
versions = (AppVersion.objects.values_list('application', 'version')
|
||||
|
|
|
@ -4,6 +4,13 @@ import amo.models
|
|||
from versions import compare
|
||||
|
||||
|
||||
class ApplicationManager(amo.models.ManagerBase):
|
||||
|
||||
def supported(self):
|
||||
"""Exclude unsupported apps."""
|
||||
return self.exclude(supported=False)
|
||||
|
||||
|
||||
class Application(amo.models.ModelBase):
|
||||
|
||||
guid = models.CharField(max_length=255, default='')
|
||||
|
@ -12,6 +19,8 @@ class Application(amo.models.ModelBase):
|
|||
# name = TranslatedField()
|
||||
# shortname = TranslatedField()
|
||||
|
||||
objects = ApplicationManager()
|
||||
|
||||
class Meta:
|
||||
db_table = 'applications'
|
||||
|
||||
|
|
|
@ -50,6 +50,17 @@ class TestApplication(amo.tests.TestCase):
|
|||
eq_(unicode(model_app), unicode(static_app.pretty))
|
||||
|
||||
|
||||
class TestApplicationManager(amo.tests.TestCase):
|
||||
fixtures = ['applications/all_apps.json']
|
||||
|
||||
def test_default_manager(self):
|
||||
eq_(Application.objects.count(), 6)
|
||||
|
||||
def test_supported(self):
|
||||
Application.objects.latest('pk').update(supported=False)
|
||||
eq_(Application.objects.supported().count(), 5)
|
||||
|
||||
|
||||
class TestViews(amo.tests.TestCase):
|
||||
fixtures = ['base/apps', 'base/appversion']
|
||||
|
||||
|
|
Двоичный файл не отображается.
|
@ -438,6 +438,19 @@ class TestParseXpi(amo.tests.TestCase):
|
|||
result = self.parse(filename='strict-compat.xpi')
|
||||
eq_(result['strict_compatibility'], True)
|
||||
|
||||
def test_unsupported_version_only(self):
|
||||
guid = '{aa3c5121-dab2-40e2-81ca-7ea25febc110}'
|
||||
android = Application.objects.get(guid=guid)
|
||||
# Make sure supported application and version exist.
|
||||
AppVersion.objects.create(application=android, version="30.0")
|
||||
AppVersion.objects.create(application=android, version="32.0")
|
||||
android.update(supported=True)
|
||||
result = self.parse(filename='unsupported_version_only.xpi')
|
||||
eq_(result['apps'][0].appdata.guid, guid)
|
||||
android.update(supported=False)
|
||||
result = self.parse(filename='unsupported_version_only.xpi')
|
||||
eq_(result['apps'], [])
|
||||
|
||||
|
||||
class TestParseAlternateXpi(amo.tests.TestCase, amo.tests.AMOPaths):
|
||||
# This install.rdf is completely different from our other xpis.
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import collections
|
||||
import glob
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
@ -20,15 +19,14 @@ from zipfile import BadZipfile, ZipFile
|
|||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
from django.utils.translation import trans_real as translation
|
||||
from django.core.files.storage import default_storage as storage
|
||||
|
||||
import rdflib
|
||||
from tower import ugettext as _
|
||||
|
||||
import amo
|
||||
from amo.utils import rm_local_tmp_dir, strip_bom, to_language
|
||||
from applications.models import AppVersion
|
||||
from amo.utils import rm_local_tmp_dir
|
||||
from applications.models import AppVersion, Application
|
||||
from versions.compare import version_int as vint
|
||||
|
||||
|
||||
|
@ -42,12 +40,14 @@ class ParseError(forms.ValidationError):
|
|||
VERSION_RE = re.compile('^[-+*.\w]{,32}$')
|
||||
SIGNED_RE = re.compile('^META\-INF/(\w+)\.(rsa|sf)$')
|
||||
# The default update URL.
|
||||
default = ('https://versioncheck.addons.mozilla.org/update/VersionCheck.php?'
|
||||
default = (
|
||||
'https://versioncheck.addons.mozilla.org/update/VersionCheck.php?'
|
||||
'reqVersion=%REQ_VERSION%&id=%ITEM_ID%&version=%ITEM_VERSION%&'
|
||||
'maxAppVersion=%ITEM_MAXAPPVERSION%&status=%ITEM_STATUS%&appID=%APP_ID%&'
|
||||
'appVersion=%APP_VERSION%&appOS=%APP_OS%&appABI=%APP_ABI%&'
|
||||
'locale=%APP_LOCALE%¤tAppVersion=%CURRENT_APP_VERSION%&'
|
||||
'updateType=%UPDATE_TYPE%')
|
||||
'updateType=%UPDATE_TYPE%'
|
||||
)
|
||||
|
||||
|
||||
def get_filepath(fileorpath):
|
||||
|
@ -156,6 +156,8 @@ class Extractor(object):
|
|||
app = amo.APP_GUIDS.get(self.find('id', ctx))
|
||||
if not app:
|
||||
continue
|
||||
if not Application.objects.supported().filter(guid=app.guid).exists():
|
||||
continue
|
||||
try:
|
||||
qs = AppVersion.objects.filter(application=app.id)
|
||||
min = qs.get(version=self.find('minVersion', ctx))
|
||||
|
|
|
@ -361,6 +361,9 @@
|
|||
});
|
||||
if (excluded) {
|
||||
var msg = gettext('Some platforms are not available for this type of add-on.');
|
||||
if ($('.platform input[type=checkbox]').length === $('.platform input[type=checkbox]:disabled').length) {
|
||||
msg = gettext('Sorry, no supported platform has been found.');
|
||||
}
|
||||
$('.platform').prepend(
|
||||
format('<ul class="errorlist"><li>{0}</li></ul>',
|
||||
msg));
|
||||
|
|
|
@ -97,7 +97,7 @@ statsd==2.0.3
|
|||
suds==0.4
|
||||
|
||||
## Not on pypi.
|
||||
-e git+https://github.com/mozilla/amo-validator.git@0acfa344cac090c52618dc1539f759ea1b1e318e#egg=amo-validator
|
||||
-e git+https://github.com/mozilla/amo-validator.git@71670d04e84408f616ca94cca69c8a51b9a46bd6#egg=amo-validator
|
||||
-e git+https://github.com/jbalogh/django-queryset-transform@a1ba6ae41bd86f5bb9ff66fb56614e0fafe6e022#egg=django-queryset-transform
|
||||
-e git+https://github.com/miracle2k/django-tables.git@546f339308103880c823b2056830fcdc9220edd0#egg=django-tables
|
||||
-e git+https://github.com/mozilla/happyforms.git@729612c2a824a7e8283d416d2084bf506c671e24#egg=happyforms
|
||||
|
|
Загрузка…
Ссылка в новой задаче