本文整理汇总了Python中addons.models.AddonCategory.creatured_random方法的典型用法代码示例。如果您正苦于以下问题:Python AddonCategory.creatured_random方法的具体用法?Python AddonCategory.creatured_random怎么用?Python AddonCategory.creatured_random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类addons.models.AddonCategory
的用法示例。
在下文中一共展示了AddonCategory.creatured_random方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _landing
# 需要导入模块: from addons.models import AddonCategory [as 别名]
# 或者: from addons.models.AddonCategory import creatured_random [as 别名]
def _landing(request, category=None):
if category:
featured = ''
category = get_list_or_404(
Category.objects.filter(type=amo.ADDON_PERSONA,
slug=category))[0]
popular = (Addon.objects.public()
.filter(type=amo.ADDON_PERSONA,
addoncategory__category__id=category.id)
.order_by('-persona__popularity')[:12])
categories, filter, base, category = personas_listing(request,
category.slug)
ids = AddonCategory.creatured_random(category, request.LANG)
featured = manual_order(base, ids, pk_name="addons.id")[:12]
else:
popular = (Addon.objects.public().filter(type=amo.ADDON_PERSONA)
.order_by('-persona__popularity')[:12])
featured = get_featured_personas(request, num_personas=12)
return jingo.render(request, 'themes/landing.html', {
'category': category,
'popular': popular,
'featured': featured,
})
示例2: personas
# 需要导入模块: from addons.models import AddonCategory [as 别名]
# 或者: from addons.models.AddonCategory import creatured_random [as 别名]
def personas(request, category=None, template=None):
categories, filter, base, category = personas_listing(request, category)
# Pass the count from base instead of letting it come from
# filter.qs.count() since that would join against personas.
count = category.count if category else base.count()
if ('sort' not in request.GET and ((request.MOBILE and not category) or
(not request.MOBILE and count > 4))):
template += 'category_landing.html'
else:
template += 'grid.html'
addons = amo.utils.paginate(request, filter.qs, 30, count=count)
if category:
ids = AddonCategory.creatured_random(category, request.LANG)
featured = manual_order(base, ids, pk_name="addons.id")
else:
ids = Addon.featured_random(request.APP, request.LANG)
featured = manual_order(base, ids, pk_name="addons.id")
ctx = {'categories': categories, 'category': category, 'addons': addons,
'filter': filter, 'sorting': filter.field, 'sort_opts': filter.opts,
'featured': featured, 'search_cat': 'personas',
'is_homepage': category is None and 'sort' not in request.GET}
return jingo.render(request, template, ctx)
示例3: personas
# 需要导入模块: from addons.models import AddonCategory [as 别名]
# 或者: from addons.models.AddonCategory import creatured_random [as 别名]
def personas(request, category=None, template=None):
categories, filter, base, category = personas_listing(request, category)
# Pass the count from base instead of letting it come from
# filter.qs.count() since that would join against personas.
count = category.count if category else base.count()
if "sort" not in request.GET and ((request.MOBILE and not category) or (not request.MOBILE and count > 4)):
template += "category_landing.html"
else:
template += "grid.html"
addons = amo.utils.paginate(request, filter.qs, 30, count=count)
if category:
ids = AddonCategory.creatured_random(category, request.LANG)
featured = manual_order(base, ids, pk_name="addons.id")
else:
ids = Addon.featured_random(request.APP, request.LANG)
featured = manual_order(base, ids, pk_name="addons.id")
ctx = {
"categories": categories,
"category": category,
"addons": addons,
"filter": filter,
"sorting": filter.field,
"sort_opts": filter.opts,
"featured": featured,
"search_cat": "personas",
"is_homepage": category is None and "sort" not in request.GET,
}
return jingo.render(request, template, ctx)
示例4: creatured
# 需要导入模块: from addons.models import AddonCategory [as 别名]
# 或者: from addons.models.AddonCategory import creatured_random [as 别名]
def creatured(request, category):
TYPE = amo.ADDON_EXTENSION
q = Category.objects.filter(application=request.APP.id, type=TYPE)
category = get_object_or_404(q, slug=category)
ids = AddonCategory.creatured_random(category, request.LANG)
addons = manual_order(Addon.objects.public(), ids, pk_name="addons.id")
return render(request, "browse/creatured.html", {"addons": addons, "category": category, "sorting": "featured"})
示例5: personas
# 需要导入模块: from addons.models import AddonCategory [as 别名]
# 或者: from addons.models.AddonCategory import creatured_random [as 别名]
def personas(request, category=None):
categories, filter, base, category = personas_listing(request, category)
# Pass the count from base instead of letting it come from
# filter.qs.count() since that would join against personas.
count = category.count if category else base.count()
if 'sort' in request.GET or count < 5:
template = 'grid.html'
else:
template = 'category_landing.html'
addons = amo.utils.paginate(request, filter.qs, 30, count=count)
if category:
ids = AddonCategory.creatured_random(category, request.LANG)
featured = manual_order(base, ids, pk_name="addons.id")
else:
ids = Addon.featured_random(request.APP, request.LANG)
featured = manual_order(base, ids, pk_name="addons.id")
is_homepage = category is None and 'sort' not in request.GET
return jingo.render(request, 'browse/personas/' + template,
{'categories': categories, 'category': category,
'filter': filter, 'addons': addons,
'featured': featured, 'is_homepage': is_homepage,
'search_cat': 'personas'})
示例6: creatured
# 需要导入模块: from addons.models import AddonCategory [as 别名]
# 或者: from addons.models.AddonCategory import creatured_random [as 别名]
def creatured(request, category):
TYPE = amo.ADDON_EXTENSION
q = Category.objects.filter(application=request.APP.id, type=TYPE)
category = get_object_or_404(q, slug=category)
ids = AddonCategory.creatured_random(category, request.LANG)
addons = manual_order(Addon.objects.public(), ids, pk_name='addons.id')
return render(request, 'browse/creatured.html',
{'addons': addons, 'category': category,
'sorting': 'featured'})
示例7: personas
# 需要导入模块: from addons.models import AddonCategory [as 别名]
# 或者: from addons.models.AddonCategory import creatured_random [as 别名]
def personas(request, category=None, template=None):
listing = personas_listing(request, category)
# I guess this was a Complete Theme after all.
if isinstance(listing, (HttpResponsePermanentRedirect, HttpResponseRedirect)):
return listing
categories, filter_, base, cat = listing
if filter_.field == "up-and-coming":
# Almost hardcoding the number of element because performing
# `filter_.qs.count()` is a performance killer. We're still
# verifying the `base.count()` for the template switch below.
base_count = base.count()
count = (
base_count if base_count < MIN_COUNT_FOR_LANDING else PAGINATE_PERSONAS_BY * settings.PERSONA_DEFAULT_PAGES
)
else:
# Pass the count from base instead of letting it come from
# filter_.qs.count() since that would join against personas.
count = cat.count if cat else base.count()
addons = amo.utils.paginate(request, filter_.qs, PAGINATE_PERSONAS_BY, count=count)
if "sort" not in request.GET and (
(request.MOBILE and not cat) or (not request.MOBILE and count > MIN_COUNT_FOR_LANDING)
):
template += "category_landing.html"
else:
template += "grid.html"
if cat:
ids = AddonCategory.creatured_random(cat, request.LANG)
featured = manual_order(base, ids, pk_name="addons.id")
else:
ids = Addon.featured_random(request.APP, request.LANG)
featured = manual_order(base, ids, pk_name="addons.id")
ctx = {
"categories": categories,
"category": cat,
"addons": addons,
"filter": filter_,
"sorting": filter_.field,
"sort_opts": filter_.opts,
"featured": featured,
"search_cat": "themes",
"is_homepage": cat is None and "sort" not in request.GET,
}
return render(request, template, ctx)
示例8: __init__
# 需要导入模块: from addons.models import AddonCategory [as 别名]
# 或者: from addons.models.AddonCategory import creatured_random [as 别名]
def __init__(self, request, base, category, key, default):
self.category = category
self.ids = AddonCategory.creatured_random(category, request.LANG)
super(CategoryLandingFilter, self).__init__(request, base, key,
default)