• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python forms.ApiSearchForm类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mkt.search.forms.ApiSearchForm的典型用法代码示例。如果您正苦于以下问题:Python ApiSearchForm类的具体用法?Python ApiSearchForm怎么用?Python ApiSearchForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ApiSearchForm类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_list

    def get_list(self, request=None, **kwargs):
        form = ApiSearchForm(request.GET if request else None)
        if not form.is_valid():
            raise self.form_errors(form)

        # Pluck out status first since it forms part of the base query, but
        # only for privileged users.
        status = form.cleaned_data['status']
        if status != amo.STATUS_PUBLIC and not (
            acl.action_allowed(request, 'Apps', 'Review') or
            acl.action_allowed(request, 'Admin', '%')):
            return http.HttpUnauthorized(
                content=json.dumps(
                    {'reason': 'Unauthorized to filter by status.'}))

        # Search specific processing of the results.
        region = getattr(request, 'REGION', mkt.regions.WORLDWIDE)
        qs = _get_query(region, gaia=request.GAIA, mobile=request.MOBILE,
                        tablet=request.TABLET, status=status)
        qs = _filter_search(request, qs, form.cleaned_data, region=region)
        paginator = self._meta.paginator_class(request.GET, qs,
            resource_uri=self.get_resource_list_uri(),
            limit=self._meta.limit)
        page = paginator.page()

        # Rehydrate the results as per tastypie.
        objs = [self.build_bundle(obj=obj, request=request)
                for obj in page['objects']]
        page['objects'] = [self.full_dehydrate(bundle) for bundle in objs]
        # This isn't as quite a full as a full TastyPie meta object,
        # but at least it's namespaced that way and ready to expand.
        return self.create_response(request, page)
开发者ID:bsmedberg,项目名称:zamboni,代码行数:32,代码来源:api.py


示例2: _filter

 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,代码行数:8,代码来源:test_filters.py


示例3: get_list

    def get_list(self, request=None, **kwargs):
        form = ApiSearchForm(request.GET if request else None)
        if not form.is_valid():
            raise self.form_errors(form)

        # Search specific processing of the results.
        qs = _get_query(request, form, form.cleaned_data)
        qs = _filter_search(qs, form.cleaned_data)
        res = amo.utils.paginate(request, qs)

        # Rehydrate the results as per tastypie.
        bundles = [self.build_bundle(obj=obj, request=request) for obj in res.object_list]
        objs = [self.full_dehydrate(bundle) for bundle in bundles]
        # This isn't as quite a full as a full TastyPie meta object,
        # but at least it's namespaced that way and ready to expand.
        return self.create_response(request, {"objects": objs, "meta": {}})
开发者ID:canuckistani,项目名称:zamboni,代码行数:16,代码来源:api.py


示例4: get_list

    def get_list(self, request=None, **kwargs):
        form = ApiSearchForm(request.GET if request else None)
        if not form.is_valid():
            raise self.form_errors(form)

        # Search specific processing of the results.
        region = getattr(request, 'REGION', mkt.regions.WORLDWIDE)
        qs = _get_query(region, gaia=request.GAIA,
                        mobile=request.MOBILE, tablet=request.TABLET)
        qs = _filter_search(qs, form.cleaned_data, region=region)
        res = amo.utils.paginate(request, qs)

        # Rehydrate the results as per tastypie.
        bundles = [self.build_bundle(obj=obj, request=request)
                   for obj in res.object_list]
        objs = [self.full_dehydrate(bundle) for bundle in bundles]
        # This isn't as quite a full as a full TastyPie meta object,
        # but at least it's namespaced that way and ready to expand.
        return self.create_response(request, {'objects': objs, 'meta': {}})
开发者ID:bearstech,项目名称:zamboni,代码行数:19,代码来源:api.py


示例5: get_list

    def get_list(self, request=None, **kwargs):
        form = ApiSearchForm(request.GET if request else None)
        if not form.is_valid():
            raise self.form_errors(form)

        is_admin = acl.action_allowed(request, "Admin", "%")
        is_reviewer = acl.action_allowed(request, "Apps", "Review")

        # Pluck out status and addon type first since it forms part of the base
        # query, but only for privileged users.
        status = form.cleaned_data["status"]
        addon_type = form.cleaned_data["type"]

        base_filters = {"type": addon_type}

        if status and (status == "any" or status != amo.STATUS_PUBLIC):
            if is_admin or is_reviewer:
                base_filters["status"] = status
            else:
                return http.HttpUnauthorized(content=json.dumps({"reason": _("Unauthorized to filter by status.")}))

        # Search specific processing of the results.
        region = getattr(request, "REGION", mkt.regions.WORLDWIDE)
        qs = _get_query(region, gaia=request.GAIA, mobile=request.MOBILE, tablet=request.TABLET, filters=base_filters)
        qs = _filter_search(request, qs, form.cleaned_data, region=region)
        paginator = self._meta.paginator_class(
            request.GET, qs, resource_uri=self.get_resource_list_uri(), limit=self._meta.limit
        )
        page = paginator.page()

        # Rehydrate the results as per tastypie.
        objs = [self.build_bundle(obj=obj, request=request) for obj in page["objects"]]
        page["objects"] = [self.full_dehydrate(bundle) for bundle in objs]
        # This isn't as quite a full as a full TastyPie meta object,
        # but at least it's namespaced that way and ready to expand.
        return self.create_response(request, page)
开发者ID:sandy-slin,项目名称:zamboni,代码行数:36,代码来源:api.py


示例6: get_search_data

 def get_search_data(self, request):
     form = ApiSearchForm(request.GET if request else None)
     if not form.is_valid():
         raise self.form_errors(form)
     return form.cleaned_data
开发者ID:kmaglione,项目名称:zamboni,代码行数:5,代码来源:api.py


示例7: _get_search_form

def _get_search_form(request):
    form = ApiSearchForm()
    fields = [f.name for f in form.visible_fields() + form.hidden_fields()]
    get = dict((k, v) for k, v in request.GET.items() if k in fields)
    return ApiSearchForm(get or None)
开发者ID:wraithan,项目名称:zamboni,代码行数:5,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python views._filter_search函数代码示例发布时间:2022-05-27
下一篇:
Python views_themes._get_themes函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap