本文整理汇总了Python中virtualfolder.models.VirtualFolder.get_matching_for方法的典型用法代码示例。如果您正苦于以下问题:Python VirtualFolder.get_matching_for方法的具体用法?Python VirtualFolder.get_matching_for怎么用?Python VirtualFolder.get_matching_for使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类virtualfolder.models.VirtualFolder
的用法示例。
在下文中一共展示了VirtualFolder.get_matching_for方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_directory_item
# 需要导入模块: from virtualfolder.models import VirtualFolder [as 别名]
# 或者: from virtualfolder.models.VirtualFolder import get_matching_for [as 别名]
def make_directory_item(directory):
filters = {}
if VirtualFolder.get_matching_for(directory.pootle_path).count():
# The directory has virtual folders, so append priority sorting to URL.
filters['sort'] = 'priority'
item = make_generic_item(directory, **filters)
item.update({
'icon': 'folder',
})
return item
示例2: get_vfolders
# 需要导入模块: from virtualfolder.models import VirtualFolder [as 别名]
# 或者: from virtualfolder.models.VirtualFolder import get_matching_for [as 别名]
def get_vfolders(directory, all_vfolders=False):
"""Return a list of virtual folders for this ``directory``.
The elements of the list are dictionaries which keys are populated after
in the templates.
If ``all_vfolders`` is True then all the virtual folders matching the
provided directory are returned. If not only the visible ones are returned.
"""
if all_vfolders:
return [make_vfolder_item(vf, directory.pootle_path)
for vf in VirtualFolder.get_matching_for(directory.pootle_path)]
return [make_vfolder_item(vf, directory.pootle_path)
for vf in VirtualFolder.get_visible_for(directory.pootle_path)]
示例3: get_browser_context
# 需要导入模块: from virtualfolder.models import VirtualFolder [as 别名]
# 或者: from virtualfolder.models.VirtualFolder import get_matching_for [as 别名]
def get_browser_context(request):
"""Returns a common context for browser pages.
:param request: a :cls:`django.http.HttpRequest` object.
"""
resource_obj = request.resource_obj
resource_path = getattr(request, 'resource_path', '')
filters = {}
if (not isinstance(resource_obj, Store) and
VirtualFolder.get_matching_for(request.pootle_path).count()):
filters['sort'] = 'priority'
url_action_continue = resource_obj.get_translate_url(state='incomplete',
**filters)
url_action_fixcritical = resource_obj.get_critical_url(**filters)
url_action_review = resource_obj.get_translate_url(state='suggestions',
**filters)
url_action_view_all = resource_obj.get_translate_url(state='all')
return {
'page': 'browse',
'pootle_path': request.pootle_path,
'resource_obj': resource_obj,
'resource_path': resource_path,
'resource_path_parts': get_path_parts(resource_path),
'translation_states': get_translation_states(resource_obj),
'check_categories': get_qualitycheck_schema(resource_obj),
'url_action_continue': url_action_continue,
'url_action_fixcritical': url_action_fixcritical,
'url_action_review': url_action_review,
'url_action_view_all': url_action_view_all,
}