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


Python DocumentController.check_permission方法代码示例

本文整理汇总了Python中openPLM.plmapp.controllers.DocumentController.check_permission方法的典型用法代码示例。如果您正苦于以下问题:Python DocumentController.check_permission方法的具体用法?Python DocumentController.check_permission怎么用?Python DocumentController.check_permission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openPLM.plmapp.controllers.DocumentController的用法示例。


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

示例1: search

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import check_permission [as 别名]
def search(request, editable_only="true", with_file_only="true"):
    """
    Returns all objects matching a query.

    :param editable_only: if ``"true"`` (the default), returns only editable objects
    :param with_file_only: if ``"true"`` (the default), returns only documents with 
                           at least one file

    :implements: :func:`http_api.search`
    """
    if request.GET and "type" in request.GET:
        attributes_form = forms.TypeForm(request.GET)
        if attributes_form.is_valid():
            query_dict = {}
            cls = models.get_all_plmobjects()[attributes_form.cleaned_data["type"]]
            extra_attributes_form = forms.get_search_form(cls, request.GET)
            results = cls.objects.all()
            if extra_attributes_form.is_valid():
                results = extra_attributes_form.search(results)
                objects = []
                for res in results:
                    if editable_only == "false" or res.is_editable:
                        if with_file_only == "true" and hasattr(res, "files") \
                           and not bool(res.files):
                            continue
                        if editable_only == "true":
                            obj = DocumentController(res, request.user)
                            if not obj.check_permission("owner", False):
                                continue
                        objects.append(object_to_dict(res))
                return {"objects" : objects} 
    return {"result": "error"}
开发者ID:esimorre,项目名称:openplm,代码行数:34,代码来源:api.py


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