当前位置: 首页>>代码示例>>Python>>正文


Python Webapp.from_search方法代码示例

本文整理汇总了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()
开发者ID:,项目名称:,代码行数:9,代码来源:

示例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)
开发者ID:bobsilverberg,项目名称:zamboni,代码行数:27,代码来源:serializers.py

示例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)
开发者ID:anushbmx,项目名称:zamboni,代码行数:32,代码来源:serializers.py

示例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)
开发者ID:unghost,项目名称:zamboni,代码行数:30,代码来源:serializers.py

示例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()
开发者ID:unghost,项目名称:zamboni,代码行数:9,代码来源:test_filters.py

示例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()
开发者ID:kodypeterson,项目名称:zamboni,代码行数:10,代码来源:test_filters.py

示例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()
开发者ID:kylewu,项目名称:zamboni,代码行数:10,代码来源:test_filters.py

示例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,
     )
开发者ID:,项目名称:,代码行数:11,代码来源:

示例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]
开发者ID:,项目名称:,代码行数:20,代码来源:

示例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)]
开发者ID:pombredanne,项目名称:zamboni,代码行数:21,代码来源:serializers.py

示例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")
开发者ID:,项目名称:,代码行数:4,代码来源:

示例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')
开发者ID:markgif,项目名称:zamboni,代码行数:6,代码来源:views.py

示例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)
开发者ID:kylewu,项目名称:zamboni,代码行数:5,代码来源:views.py

示例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')
开发者ID:bsmedberg,项目名称:zamboni,代码行数:5,代码来源:views.py

示例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)
开发者ID:unghost,项目名称:zamboni,代码行数:4,代码来源:api.py


注:本文中的mkt.webapps.models.Webapp.from_search方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。