本文整理汇总了Python中mkt.webapps.models.Webapp.from_search方法的典型用法代码示例。如果您正苦于以下问题:Python Webapp.from_search方法的具体用法?Python Webapp.from_search怎么用?Python Webapp.from_search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mkt.webapps.models.Webapp
的用法示例。
在下文中一共展示了Webapp.from_search方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _filter
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def _filter(self, req, filters, sorting=None):
form = ApiSearchForm(filters)
if form.is_valid():
qs = Webapp.from_search().facet("category")
return _filter_search(self.req, qs, form.cleaned_data, sorting)._build_query()
else:
return form.errors.copy()
示例2: field_to_native_es
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def field_to_native_es(self, obj, request):
"""
A version of field_to_native that uses ElasticSearch to fetch the apps
belonging to the collection instead of SQL.
Relies on a FeaturedSearchView instance in self.context['view']
to properly rehydrate results returned by ES.
"""
profile = get_feature_profile(request)
region = self.context['view'].get_region(request)
qs = Webapp.from_search(request, region=region)
filters = {'collection.id': obj.pk}
if profile:
filters.update(**profile.to_kwargs(prefix='features.has_'))
qs = qs.filter(**filters).order_by({
'collection.order': {
'order': 'asc',
'nested_filter': {
'term': {'collection.id': obj.pk}
}
}
})
return self.to_native_es(qs)
示例3: field_to_native_es
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def field_to_native_es(self, obj, request):
"""
A version of field_to_native that uses ElasticSearch to fetch the apps
belonging to the collection instead of SQL.
Relies on a FeaturedSearchView instance in self.context['view']
to properly rehydrate results returned by ES.
"""
profile = get_feature_profile(request)
region = self.context['view'].get_region_from_request(request)
device = self._get_device(request)
_rget = lambda d: getattr(request, d, False)
qs = Webapp.from_search(request, region=region, gaia=_rget('GAIA'),
mobile=_rget('MOBILE'), tablet=_rget('TABLET'))
filters = {'collection.id': obj.pk}
if device and device != amo.DEVICE_DESKTOP:
filters['device'] = device.id
if profile:
filters.update(**profile.to_kwargs(prefix='features.has_'))
qs = qs.filter(**filters).order_by({
'collection.order': {
'order': 'asc',
'nested_filter': {
'term': {'collection.id': obj.pk}
}
}
})
return self.to_native(qs, use_es=True)
示例4: field_to_native_es
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def field_to_native_es(self, obj, request):
"""
A version of field_to_native that uses ElasticSearch to fetch the apps
belonging to the collection instead of SQL.
Relies on a FeaturedSearchView instance in self.context['view']
to properly rehydrate results returned by ES.
"""
profile = get_feature_profile(request)
region = self.context['view'].get_region(request)
platform = mkt.PLATFORM_LOOKUP.get(request.GET.get('dev'))
_rget = lambda d: getattr(request, d, False)
qs = Webapp.from_search(request, region=region)
filters = {'collection.id': obj.pk}
filters.update(**self._get_filters(request, es=True))
if profile:
filters.update(**profile.to_kwargs(prefix='features.has_'))
qs = qs.filter(**filters).order_by({
'collection.order': {
'order': 'asc',
'nested_filter': {
'term': {'collection.id': obj.pk}
}
}
})
return self.to_native_es(qs)
示例5: _filter
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def _filter(self, req, filters, sorting=None, **kwargs):
form = self.form_class(filters)
if form.is_valid():
qs = Webapp.from_search(self.req, **kwargs)
return _filter_search(self.req, qs, form.cleaned_data, sorting)._build_query()
else:
return form.errors.copy()
示例6: _filter
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def _filter(self, req, filters, **kwargs):
form = ApiSearchForm(filters)
if form.is_valid():
qs = Webapp.from_search(self.req, **kwargs)
return _filter_search(
self.req, qs, form.cleaned_data)._build_query()
else:
return form.errors.copy()
示例7: _filter
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def _filter(self, req, filters, **kwargs):
form = self.form_class(filters)
if form.is_valid():
qs = Webapp.from_search(self.req, **kwargs)
return _filter_search(
self.req, qs, form.cleaned_data).to_dict()
else:
return form.errors.copy()
示例8: get_query
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def get_query(self, request, base_filters=None, region=None):
return Webapp.from_search(
request,
region=region,
gaia=request.GAIA,
mobile=request.MOBILE,
tablet=request.TABLET,
filter_overrides=base_filters,
)
示例9: field_to_native_es
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def field_to_native_es(self, obj, request):
"""
A version of field_to_native that uses ElasticSearch to fetch the apps
belonging to the collection instead of SQL.
Relies on a FeaturedSearchView instance in self.context['view']
to properly rehydrate results returned by ES.
"""
profile = get_feature_profile(request)
region = self.context["view"].get_region(request)
qs = Webapp.from_search(request, region=region)
filters = {"collection.id": obj.pk}
if profile:
filters.update(**profile.to_kwargs(prefix="features.has_"))
qs = qs.filter(**filters).order_by("collection.order")
return [self.to_native_es(app) for app in qs]
示例10: field_to_native_es
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def field_to_native_es(self, obj, request):
"""
A version of field_to_native that uses ElasticSearch to fetch the apps
belonging to the collection instead of SQL.
Relies on a SearchResource instance in self.context['search_resource']
to properly rehydrate results returned by ES.
"""
search_resource = self.context["search_resource"]
profile = get_feature_profile(request)
region = search_resource.get_region(request)
qs = Webapp.from_search(request, region=region)
filters = {"collection.id": obj.pk}
if profile and waffle.switch_is_active("buchets"):
filters.update(**profile.to_kwargs(prefix="features.has_"))
qs = qs.filter(**filters).order_by("collection.order")
return [bundle.data for bundle in search_resource.rehydrate_results(request, qs)]
示例11: _get_query
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def _get_query(region):
return Webapp.from_search(region=region).facet("category")
示例12: _get_query
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def _get_query(region, gaia, mobile, tablet, filters=None, new_idx=False):
return Webapp.from_search(
region=region, gaia=gaia, mobile=mobile, tablet=tablet,
filter_overrides=filters, new_idx=new_idx).facet('category')
示例13: get_query
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def get_query(self, request, region=None):
return Webapp.from_search(request, region=region, gaia=request.GAIA,
mobile=request.MOBILE, tablet=request.TABLET)
示例14: _get_query
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def _get_query(region, gaia, mobile, tablet, status=amo.STATUS_PUBLIC):
return Webapp.from_search(region=region, gaia=gaia, mobile=mobile,
tablet=tablet, status=status).facet('category')
示例15: get_query
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import from_search [as 别名]
def get_query(self, request, base_filters=None, region=None):
return Webapp.from_search(request, region=region, filter_overrides=base_filters)