Exemple #1
0
 def test_category_url(self):
     """Every type must have a url path for its categories."""
     for t in amo.ADDON_TYPE.keys():
         if t == amo.ADDON_DICT:
             continue  # Language packs don't have categories.
         cat = Category(type=AddonType(id=t), slug='omg')
         assert cat.get_url_path()
Exemple #2
0
def _side_nav(context, addon_type):
    request = context['request']
    qs = Category.objects.filter(application=request.APP.id, weight__gte=0)
    sort_key = attrgetter('weight', 'name')
    categories = sorted(qs.filter(type=addon_type), key=sort_key)
    ctx = dict(request=request,
               base_url=AddonType(addon_type).get_url_path(),
               categories=categories,
               addon_type=addon_type)
    return jinja2.Markup(env.get_template('amo/side_nav.html').render(ctx))
Exemple #3
0
def _side_nav(context, addon_type, cat):
    # Prevent helpers generating circular imports.
    from addons.models import Category, AddonType
    request = context['request']
    qs = Category.objects.filter(weight__gte=0)
    if addon_type not in (amo.ADDON_PERSONA, amo.ADDON_WEBAPP):
        qs = qs.filter(application=request.APP.id)
    sort_key = attrgetter('weight', 'name')
    categories = sorted(qs.filter(type=addon_type), key=sort_key)
    if cat:
        base_url = cat.get_url_path()
    else:
        base_url = AddonType(addon_type).get_url_path()
    ctx = dict(request=request, base_url=base_url, categories=categories,
               addon_type=addon_type, amo=amo)
    return jinja2.Markup(env.get_template('amo/side_nav.html').render(ctx))