- {% if addon.type == 10 %} + {% if addon.type == 10 and addon.current_previews|length > 0 %}
{% endif %}
diff --git a/src/olympia/addons/templates/addons/impala/listing/items.html b/src/olympia/addons/templates/addons/impala/listing/items.html index 9af293ca6063..3d4f9dd5411b 100644 --- a/src/olympia/addons/templates/addons/impala/listing/items.html +++ b/src/olympia/addons/templates/addons/impala/listing/items.html @@ -2,7 +2,7 @@ {% for addon in addons %}
- {% if addon.type == 10 %} + {% if addon.type == 10 and addon.current_previews|length > 0 %} {% endif %}

diff --git a/src/olympia/constants/categories.py b/src/olympia/constants/categories.py index d8589e132ed9..18d8be7ad932 100644 --- a/src/olympia/constants/categories.py +++ b/src/olympia/constants/categories.py @@ -131,7 +131,22 @@ def _immutable(self, *args): 'solid': StaticCategory(id=118, name=_(u'Solid')), 'sports': StaticCategory(id=104, name=_(u'Sports')), 'websites': StaticCategory(id=116, name=_(u'Websites')) - } + }, + ADDON_STATICTHEME: { + 'abstract': StaticCategory(id=300, name=_(u'Abstract')), + 'causes': StaticCategory(id=320, name=_(u'Causes')), + 'fashion': StaticCategory(id=324, name=_(u'Fashion')), + 'film-and-tv': StaticCategory(id=326, name=_(u'Film and TV')), + 'holiday': StaticCategory(id=328, name=_(u'Holiday')), + 'music': StaticCategory(id=322, name=_(u'Music')), + 'nature': StaticCategory(id=302, name=_(u'Nature')), + 'other': StaticCategory(id=314, name=_(u'Other'), weight=333), + 'scenery': StaticCategory(id=306, name=_(u'Scenery')), + 'seasonal': StaticCategory(id=312, name=_(u'Seasonal')), + 'solid': StaticCategory(id=318, name=_(u'Solid')), + 'sports': StaticCategory(id=304, name=_(u'Sports')), + 'websites': StaticCategory(id=316, name=_(u'Websites')) + }, }, ANDROID.id: { ADDON_EXTENSION: { diff --git a/src/olympia/landfill/generators.py b/src/olympia/landfill/generators.py index af20ef8df439..14b1defe4f4b 100644 --- a/src/olympia/landfill/generators.py +++ b/src/olympia/landfill/generators.py @@ -21,6 +21,7 @@ from .translations import generate_translations from .user import generate_addon_user_and_category, generate_user from .version import generate_version +from ..constants.categories import CATEGORIES def _yield_name_and_cat(num, app=None, type=None): @@ -46,6 +47,7 @@ def create_addon(name, icon_type, application, **extra_kwargs): kwargs = { 'status': STATUS_PUBLIC, 'name': name, + 'description': 'This is a test description.\n\nPlease visit https://www.thunderbird.net for the latest developments on Thunderbird!', 'slug': slugify(name), 'bayesian_rating': random.uniform(1, 5), 'average_daily_users': random.randint(200, 2000), @@ -75,6 +77,11 @@ def generate_addons(num, owner, app_name, addon_type=ADDON_EXTENSION): user = generate_user(owner) app = APPS[app_name] default_icons = [x[0] for x in icons() if x[0].startswith('icon/')] + + # If the addon type isn't even specified in this app, then ignore it! + if addon_type not in CATEGORIES[app.id]: + return + for name, category in _yield_name_and_cat( num, app=app, type=addon_type): # Use one of the default icons at random. @@ -121,23 +128,25 @@ def create_theme(name, **extra_kwargs): return theme -def generate_themes(num, owner): +def generate_themes(num, owner, app_name = 'firefox'): """Generate `num` themes for the given `owner`.""" # Disconnect this signal given that we issue a reindex at the end. post_save.disconnect(update_search_index, sender=Addon, dispatch_uid='addons.search.index') user = generate_user(owner) + app = APPS[app_name] # Generate personas. - for name, category in _yield_name_and_cat( - num, app=FIREFOX, type=ADDON_PERSONA): - theme = create_theme(name=name) - generate_addon_user_and_category(theme, user, category) - generate_theme_images(theme) - generate_translations(theme) - generate_collection(theme) - generate_ratings(theme, 5) + if ADDON_PERSONA in CATEGORIES[app.id]: + for name, category in _yield_name_and_cat( + num, app=FIREFOX, type=ADDON_PERSONA): + theme = create_theme(name=name) + generate_addon_user_and_category(theme, user, category) + generate_theme_images(theme) + generate_translations(theme) + generate_collection(theme) + generate_ratings(theme, 5) # Generate static themes. - generate_addons(num, owner, 'firefox', addon_type=ADDON_STATICTHEME) + generate_addons(num, owner, app_name, addon_type=ADDON_STATICTHEME) diff --git a/src/olympia/landfill/management/commands/generate_themes.py b/src/olympia/landfill/management/commands/generate_themes.py index 74f5279edb1c..b00627965255 100644 --- a/src/olympia/landfill/management/commands/generate_themes.py +++ b/src/olympia/landfill/management/commands/generate_themes.py @@ -19,7 +19,7 @@ class Command(BaseCommand): Usage: - python manage.py generate_themes [--owner ] + python manage.py generate_themes [--owner ] [--app ] """ @@ -32,6 +32,10 @@ def add_arguments(self, parser): '--owner', action='store', dest='email', default='nobody@mozilla.org', help="Specific owner's email to be created.") + parser.add_argument( + '--app', action='store', dest='app_name', + default='firefox', + help="Specific application targeted by add-ons creation.") def handle(self, *args, **kwargs): if not settings.DEBUG: @@ -39,6 +43,7 @@ def handle(self, *args, **kwargs): 'DEBUG setting set to True.') num = int(kwargs.get('num')) email = kwargs.get('email') + app = kwargs.get('app_name') with translation.override(settings.LANGUAGE_CODE): - generate_themes(num, email) + generate_themes(num, email, app)