move to django-mozilla-product-details and add update into the deploy (bug 671534)
This commit is contained in:
Родитель
1d582ea9d4
Коммит
8e5167578c
|
@ -6,7 +6,7 @@ import threading
|
|||
|
||||
import commonware.log
|
||||
|
||||
from product_details import firefox_versions, thunderbird_versions
|
||||
from product_details import product_details
|
||||
|
||||
from constants.applications import *
|
||||
from constants.base import *
|
||||
|
@ -78,5 +78,5 @@ class CachedProperty(object):
|
|||
|
||||
# For unproven performance gains put firefox and thunderbird parsing
|
||||
# here instead of constants
|
||||
FIREFOX.latest_version = firefox_versions['LATEST_FIREFOX_VERSION']
|
||||
THUNDERBIRD.latest_version = thunderbird_versions['LATEST_THUNDERBIRD_VERSION']
|
||||
FIREFOX.latest_version = product_details.firefox_versions['LATEST_FIREFOX_VERSION']
|
||||
THUNDERBIRD.latest_version = product_details.thunderbird_versions['LATEST_THUNDERBIRD_VERSION']
|
||||
|
|
|
@ -8,7 +8,7 @@ from django.core.validators import ValidationError
|
|||
from nose.tools import eq_, assert_raises
|
||||
|
||||
from amo.utils import slug_validator, slugify, resize_image, to_language
|
||||
|
||||
from product_details import product_details
|
||||
|
||||
u = u'Ελληνικά'
|
||||
|
||||
|
@ -77,3 +77,11 @@ def test_to_language():
|
|||
for a, b in tests:
|
||||
yield check, a, b
|
||||
|
||||
|
||||
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')
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.shortcuts import get_object_or_404
|
|||
from django.views.decorators.cache import cache_page
|
||||
|
||||
import jingo
|
||||
import product_details
|
||||
from product_details import product_details
|
||||
from mobility.decorators import mobile_template
|
||||
from tower import ugettext_lazy as _lazy
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ from files.utils import parse_addon
|
|||
from translations.models import delete_translation
|
||||
from users.models import UserProfile
|
||||
from versions.models import License, Version
|
||||
from product_details import get_regions
|
||||
from product_details import product_details
|
||||
from zadmin.models import ValidationResult
|
||||
|
||||
from . import forms, tasks, feeds, responsys, signals
|
||||
|
@ -1358,7 +1358,8 @@ def builder(request):
|
|||
|
||||
@anonymous_csrf
|
||||
def newsletter(request):
|
||||
regions = get_regions(getattr(request, 'LANG', settings.LANGUAGE_CODE))
|
||||
regions = product_details.get_regions(getattr(request, 'LANG',
|
||||
settings.LANGUAGE_CODE))
|
||||
form = forms.NewsletterForm(request.POST or None,
|
||||
regions=sorted(regions.iteritems(),
|
||||
key=operator.itemgetter(1)))
|
||||
|
|
|
@ -12,7 +12,7 @@ from tower import ugettext_lazy as _lazy
|
|||
from quieter_formset.formset import BaseModelFormSet
|
||||
|
||||
import amo
|
||||
import product_details
|
||||
from product_details import product_details
|
||||
from amo.urlresolvers import reverse
|
||||
from applications.models import Application, AppVersion
|
||||
from bandwagon.models import Collection, FeaturedCollection
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
"""
|
||||
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
|
||||
import codecs
|
||||
|
||||
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))
|
||||
|
||||
|
||||
def get_regions(locale):
|
||||
"""
|
||||
Get a list of region names for a specific locale as a
|
||||
dictionary with country codes as keys and localized names as
|
||||
values.
|
||||
"""
|
||||
|
||||
def json_file(name):
|
||||
return os.path.join(json_dir, 'regions', '%s.json' % name)
|
||||
|
||||
filepath = json_file(locale)
|
||||
|
||||
if not os.path.exists(filepath):
|
||||
filepath = json_file('en-US')
|
||||
if not os.path.exists(filepath):
|
||||
raise Exception('Unable to load region data')
|
||||
|
||||
with codecs.open(filepath, encoding='utf8') as fd:
|
||||
return json.load(fd)
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 637fa900cc4f5a743656ca6fab87e7997100a467
|
|
@ -1,13 +0,0 @@
|
|||
# -*- 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')
|
|
@ -0,0 +1 @@
|
|||
This is a placeholder for the content from: manage.py update_product_details
|
10
manage.py
10
manage.py
|
@ -31,7 +31,8 @@ for item in list(sys.path):
|
|||
sys.path[:0] = new_sys_path
|
||||
|
||||
# No third-party imports until we've added all our sitedirs!
|
||||
from django.core.management import execute_manager, setup_environ
|
||||
from django.core.management import (call_command, execute_manager,
|
||||
setup_environ)
|
||||
|
||||
try:
|
||||
import settings_local as settings
|
||||
|
@ -72,4 +73,11 @@ safe_signals.start_the_machine()
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# If product details aren't present, get them.
|
||||
from product_details import product_details
|
||||
if not product_details.last_update:
|
||||
print 'Product details missing, downloading...'
|
||||
call_command('update_product_details')
|
||||
product_details.__init__() # reload the product details
|
||||
|
||||
execute_manager(settings)
|
||||
|
|
|
@ -35,6 +35,13 @@ def update_locales(ctx):
|
|||
ctx.local("svn revert -R .")
|
||||
ctx.local("svn up")
|
||||
|
||||
|
||||
@task
|
||||
def update_products(ctx):
|
||||
with ctx.lcd(AMO_DIR):
|
||||
ctx.local('python2.6 manage.py update_product_details')
|
||||
|
||||
|
||||
@task
|
||||
def disable_cron(ctx):
|
||||
ctx.local("mv /etc/cron.d/addons-prod-maint /tmp/addons-prod-maint")
|
||||
|
@ -135,6 +142,7 @@ def start_update(ctx, tag, vendor_tag):
|
|||
def update_amo(ctx):
|
||||
# BEGIN: The normal update/push cycle.
|
||||
update_locales()
|
||||
update_products()
|
||||
compress_assets()
|
||||
schematic()
|
||||
make_crons()
|
||||
|
|
17
settings.py
17
settings.py
|
@ -6,7 +6,7 @@ import logging
|
|||
import socket
|
||||
|
||||
from django.utils.datastructures import SortedDict
|
||||
import product_details
|
||||
from django.utils.functional import lazy
|
||||
|
||||
try:
|
||||
# If we have build ids available, we'll grab them here and add them to our
|
||||
|
@ -94,9 +94,19 @@ AMO_LANGUAGES = (
|
|||
'tr', 'uk', 'vi', 'zh-CN', 'zh-TW',
|
||||
)
|
||||
|
||||
def lazy_langs():
|
||||
from django.conf import settings
|
||||
from product_details import product_details
|
||||
if not product_details.languages:
|
||||
return SortedDict()
|
||||
return SortedDict([(i.lower(), product_details.languages[i]['native'])
|
||||
for i in AMO_LANGUAGES])
|
||||
|
||||
# Where product details are stored see django-mozilla-product-details
|
||||
PROD_DETAILS_DIR = path('lib/product_json')
|
||||
|
||||
# Override Django's built-in with our native names
|
||||
LANGUAGES = SortedDict([(i.lower(), product_details.languages[i]['native'])
|
||||
for i in AMO_LANGUAGES])
|
||||
LANGUAGES = lazy(lazy_langs, SortedDict)()
|
||||
RTL_LANGUAGES = ('ar', 'fa', 'fa-IR', 'he')
|
||||
|
||||
LANGUAGE_URL_MAP = dict([(i.lower(), i) for i in AMO_LANGUAGES])
|
||||
|
@ -308,6 +318,7 @@ INSTALLED_APPS = (
|
|||
'jingo_minify',
|
||||
'pages',
|
||||
'perf',
|
||||
'product_details',
|
||||
'reviews',
|
||||
'search',
|
||||
'sharing',
|
||||
|
|
Загрузка…
Ссылка в новой задаче