本文整理汇总了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"}