本文整理汇总了Python中media_tree.admin.utils.get_request_attr函数的典型用法代码示例。如果您正苦于以下问题:Python get_request_attr函数的具体用法?Python get_request_attr怎么用?Python get_request_attr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_request_attr函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: admin_preview
def admin_preview(self, node, icons_only=False):
request = get_current_request()
template = 'admin/media_tree/filenode/includes/preview.html'
thumbnail_backend = get_media_backend(handles_media_types=(node.media_type,), supports_thumbnails=True)
if not thumbnail_backend:
icons_only = True
template = 'media_tree/filenode/includes/icon.html'
# TODO SPLIT preview.html in two: one that doesn't need media backend!
context = {
'node': node,
'preview_file': node.get_icon_file() if icons_only else node.get_preview_file(),
'class': 'collapsed' if node.is_folder() else '',
}
if not icons_only:
thumb_size_key = get_request_attr(request, 'thumbnail_size') or 'default'
context['thumbnail_size'] = app_settings.MEDIA_TREE_ADMIN_THUMBNAIL_SIZES[thumb_size_key]
thumb = thumbnail_backend.get_thumbnail(context['preview_file'], {'size': context['thumbnail_size']})
context['thumb'] = thumb
preview = render_to_string(template, context)
if node.is_folder():
preview += render_to_string(template, {
'node': node,
'preview_file': node.get_preview_file(default_name='_folder_expanded'),
'class': 'expanded'
})
return preview
开发者ID:gbezyuk,项目名称:django-media-tree,代码行数:30,代码来源:filenode_admin.py
示例2: save_model
def save_model(self, request, obj, form, change):
"""
Given a model instance save it to the database.
"""
if not change:
if not obj.node_type:
obj.node_type = get_request_attr(request, 'save_node_type', None)
super(FileNodeAdmin, self).save_model(request, obj, form, change)
开发者ID:cyber778,项目名称:django-media-tree,代码行数:8,代码来源:filenode_admin.py
示例3: get_form
def get_form(self, request, *args, **kwargs):
if get_request_attr(request, 'save_node_type', None) == FileNode.FOLDER:
self.form = FolderForm
else:
self.form = FileForm
self.fieldsets = self.form.Meta.fieldsets
form = super(FileNodeAdmin, self).get_form(request, *args, **kwargs)
return form
开发者ID:gbezyuk,项目名称:django-media-tree,代码行数:9,代码来源:filenode_admin.py
示例4: get_results
def get_results(self, request):
""" Temporarily decreases the `level` attribute of all search results
in order to prevent indendation when displaying them. """
super(FileNodeChangeList, self).get_results(request)
try:
reduce_levels = abs(int(get_request_attr(
request, 'reduce_levels', 0)))
except TypeError:
reduce_levels = 0
is_filtered = self.is_filtered(request)
if is_filtered or reduce_levels:
for item in self.result_list:
item.prevent_save()
item.actual_level = item.level
if is_filtered:
item.reduce_levels = item.level
item.level = 0
else:
item.reduce_levels = reduce_levels
item.level = max(0, item.level - reduce_levels)
开发者ID:loungelogic,项目名称:django-media-tree,代码行数:20,代码来源:change_list.py
示例5: admin_preview
def admin_preview(self, node, icons_only=False):
request = get_current_request()
template = 'admin/media_tree/filenode/includes/preview.html'
if not get_media_backend():
icons_only = True
template = 'media_tree/filenode/includes/icon.html'
# TODO SPLIT preview.html in two: one that doesn't need media backend!
thumb_size_key = get_request_attr(request, 'thumbnail_size') or 'default'
preview = render_to_string(template, {
'node': node,
'preview_file': node.get_icon_file() if icons_only else node.get_preview_file(),
'class': 'collapsed' if node.is_folder() else '',
'thumbnail_size': app_settings.MEDIA_TREE_ADMIN_THUMBNAIL_SIZES[thumb_size_key]
})
if node.is_folder():
preview += render_to_string(template, {
'node': node,
'preview_file': node.get_preview_file(default_name='_folder_expanded'),
'class': 'expanded'
})
return preview
开发者ID:quinode,项目名称:django-media-tree,代码行数:23,代码来源:filenode_admin.py
示例6: get_parent_folder
def get_parent_folder(self, request):
return get_request_attr(request, 'parent_folder', None)
开发者ID:quinode,项目名称:django-media-tree,代码行数:2,代码来源:filenode_admin.py
示例7: save_model
def save_model(self, request, obj, form, change):
if not change:
if not obj.node_type:
obj.node_type = get_request_attr(request, 'save_node_type', None)
obj.attach_user(request.user, change)
super(FileNodeAdmin, self).save_model(request, obj, form, change)
开发者ID:dzonder,项目名称:django-media-tree,代码行数:6,代码来源:old_filenode_admin.py
注:本文中的media_tree.admin.utils.get_request_attr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论