當前位置: 首頁>>代碼示例>>Python>>正文


Python AttachmentFolder.get_for_linked_object方法代碼示例

本文整理匯總了Python中indico.modules.attachments.models.folders.AttachmentFolder.get_for_linked_object方法的典型用法代碼示例。如果您正苦於以下問題:Python AttachmentFolder.get_for_linked_object方法的具體用法?Python AttachmentFolder.get_for_linked_object怎麽用?Python AttachmentFolder.get_for_linked_object使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在indico.modules.attachments.models.folders.AttachmentFolder的用法示例。


在下文中一共展示了AttachmentFolder.get_for_linked_object方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _addMaterialFrom

# 需要導入模塊: from indico.modules.attachments.models.folders import AttachmentFolder [as 別名]
# 或者: from indico.modules.attachments.models.folders.AttachmentFolder import get_for_linked_object [as 別名]
 def _addMaterialFrom(self, target, categoryPath):
     for folder in AttachmentFolder.get_for_linked_object(target, preload_event=True):
         for attachment in folder.attachments:
             if attachment.type == AttachmentType.file:
                 dst_path = posixpath.join(self._mainPath, "files", categoryPath,
                                           "{}-{}".format(attachment.id, attachment.file.filename))
                 with attachment.file.get_local_path() as file_path:
                     self._addFileFromSrc(dst_path, file_path)
開發者ID:bkolobara,項目名稱:indico,代碼行數:10,代碼來源:offlineWebsiteCreator.py

示例2: _add_material

# 需要導入模塊: from indico.modules.attachments.models.folders import AttachmentFolder [as 別名]
# 或者: from indico.modules.attachments.models.folders.AttachmentFolder import get_for_linked_object [as 別名]
 def _add_material(self, target, type_):
     for folder in AttachmentFolder.get_for_linked_object(target, preload_event=True):
         for attachment in folder.attachments:
             if not attachment.can_access(None):
                 continue
             if attachment.type == AttachmentType.file:
                 dst_path = posixpath.join(self._content_dir, "material", type_,
                                           "{}-{}".format(attachment.id, attachment.file.filename))
                 with attachment.file.get_local_path() as file_path:
                     self._copy_file(dst_path, file_path)
開發者ID:jas01,項目名稱:indico,代碼行數:12,代碼來源:offline.py

示例3: get_attached_folders

# 需要導入模塊: from indico.modules.attachments.models.folders import AttachmentFolder [as 別名]
# 或者: from indico.modules.attachments.models.folders.AttachmentFolder import get_for_linked_object [as 別名]
def get_attached_folders(linked_object, include_empty=True, include_hidden=True, preload_event=False):
    """
    Return a list of all the folders linked to an object.

    :param linked_object: The object whose attachments are to be returned
    :param include_empty: Whether to return empty folders as well.
    :param include_hidden: Include folders that the user can't see
    :param preload_event: in the process, preload all objects tied to the
                          corresponding event and keep them in cache
    """
    from indico.modules.attachments.models.folders import AttachmentFolder

    folders = AttachmentFolder.get_for_linked_object(linked_object, preload_event=preload_event)

    if not include_hidden:
        folders = [f for f in folders if f.can_view(session.user)]

    if not include_empty:
        folders = [f for f in folders if f.attachments]

    return folders
開發者ID:indico,項目名稱:indico,代碼行數:23,代碼來源:util.py


注:本文中的indico.modules.attachments.models.folders.AttachmentFolder.get_for_linked_object方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。