Merge commit '5438bc3'
This commit is contained in:
Коммит
e2f93db1e7
|
@ -10,3 +10,6 @@
|
|||
[submodule "configs"]
|
||||
path = configs
|
||||
url = git://github.com/davedash/amo-configs
|
||||
[submodule "lib/product_details/json"]
|
||||
path = lib/product_details/json
|
||||
url = git://github.com/jbalogh/mozilla-product-details.git
|
||||
|
|
|
@ -12,17 +12,18 @@ from translations.fields import TranslatedField, translations_with_fallback
|
|||
|
||||
class AddonManager(amo.models.ManagerBase):
|
||||
|
||||
def public(self):
|
||||
return self.filter(inactive=False, status=amo.STATUS_PUBLIC)
|
||||
|
||||
def featured(self, app):
|
||||
"""Get all featured add-ons for ``app`` in all locales."""
|
||||
qs = super(AddonManager, self).get_query_set()
|
||||
today = date.today()
|
||||
return qs.filter(feature__application=app.id,
|
||||
feature__start__lte=today, feature__end__gte=today)
|
||||
return self.filter(feature__application=app.id,
|
||||
feature__start__lte=today, feature__end__gte=today)
|
||||
|
||||
def category_featured(self):
|
||||
"""Get all category-featured add-ons for ``app`` in all locales."""
|
||||
qs = super(AddonManager, self).get_query_set()
|
||||
return qs.filter(addoncategory__feature=True)
|
||||
return self.filter(addoncategory__feature=True)
|
||||
|
||||
|
||||
class Addon(amo.models.ModelBase):
|
||||
|
@ -171,6 +172,14 @@ class Addon(amo.models.ModelBase):
|
|||
except IndexError:
|
||||
return settings.STATIC_URL + '/img/no-preview.png'
|
||||
|
||||
@property
|
||||
def compatible_apps(self):
|
||||
"""Shortcut to get compatible apps for the current version."""
|
||||
if self.current_version:
|
||||
return self.current_version.compatible_apps
|
||||
else:
|
||||
return {}
|
||||
|
||||
|
||||
class AddonCategory(models.Model):
|
||||
addon = models.ForeignKey(Addon)
|
||||
|
|
|
@ -24,7 +24,7 @@ class Version(amo.models.ModelBase):
|
|||
def compatible_apps(self):
|
||||
"""Get a mapping of {APP: ApplicationVersion}."""
|
||||
apps = {}
|
||||
for av in self.applicationsversions_set.select_related():
|
||||
for av in self.applicationsversions_set.select_related(depth=1):
|
||||
app_id = av.application.id
|
||||
if app_id in amo.APP_IDS:
|
||||
apps[amo.APP_IDS[app_id]] = av
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
"""
|
||||
The /json dir here is a git-svn submodule of
|
||||
http://svn.mozilla.org/libs/product-details/json/.
|
||||
|
||||
When this module is imported, we load all the .json files and insert them as
|
||||
module attributes using locals(). It's a magical and wonderful process.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
|
||||
|
||||
root = os.path.dirname(os.path.realpath(__file__))
|
||||
json_dir = os.path.join(root, 'json')
|
||||
|
||||
for filename in os.listdir(json_dir):
|
||||
if filename.endswith('.json'):
|
||||
name = os.path.splitext(filename)[0]
|
||||
path = os.path.join(json_dir, filename)
|
||||
locals()[name] = json.load(open(path))
|
|
@ -0,0 +1 @@
|
|||
Subproject commit c7ab6c8461d595d22585eaed5c09fae9f8a05032
|
|
@ -0,0 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from nose.tools import eq_
|
||||
|
||||
import product_details
|
||||
|
||||
|
||||
def test_spotcheck():
|
||||
"""Check a couple product-details files to make sure they're available."""
|
||||
languages = product_details.languages
|
||||
eq_(languages['el']['English'], 'Greek')
|
||||
eq_(languages['el']['native'], u'Ελληνικά')
|
||||
|
||||
eq_(product_details.firefox_history_major_releases['1.0'], '2004-11-09')
|
Загрузка…
Ссылка в новой задаче