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


Python AttachmentFolder.acl方法代碼示例

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


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

示例1: clone

# 需要導入模塊: from indico.modules.attachments.models.folders import AttachmentFolder [as 別名]
# 或者: from indico.modules.attachments.models.folders.AttachmentFolder import acl [as 別名]
    def clone(self, new_event, options):
        if 'attachments' not in options:
            return
        folder_mapping = {}
        attrs = get_simple_column_attrs(AttachmentFolder)
        for old_folder in self.find_folders():
            new_folder = AttachmentFolder(event_id=new_event.id, **{attr: getattr(old_folder, attr) for attr in attrs})
            if new_folder.linked_object is None:
                continue
            new_folder.acl = old_folder.acl
            db.session.add(new_folder)
            folder_mapping[old_folder] = new_folder

        attrs = get_simple_column_attrs(Attachment) - {'modified_dt'}
        for old_attachment in self.find_attachments():
            folder = folder_mapping.get(old_attachment.folder)
            if not folder:
                continue
            new_attachment = Attachment(folder=folder, user_id=old_attachment.user_id, acl=old_attachment.acl,
                                        **{attr: getattr(old_attachment, attr) for attr in attrs})
            if new_attachment.type == AttachmentType.file:
                old_file = old_attachment.file
                new_attachment.file = AttachmentFile(
                    attachment=new_attachment,
                    user_id=old_file.user_id,
                    filename=old_file.filename,
                    content_type=old_file.content_type
                )
                with old_file.open() as fd:
                    new_attachment.file.save(fd)
            db.session.add(new_attachment)

        db.session.flush()
開發者ID:hennogous,項目名稱:indico,代碼行數:35,代碼來源:clone.py

示例2: _process

# 需要導入模塊: from indico.modules.attachments.models.folders import AttachmentFolder [as 別名]
# 或者: from indico.modules.attachments.models.folders.AttachmentFolder import acl [as 別名]
 def _process(self):
     form = AttachmentFolderForm(obj=FormDefaults(is_always_visible=True), linked_object=self.object)
     if form.validate_on_submit():
         folder = AttachmentFolder(object=self.object)
         form.populate_obj(folder, skip={'acl'})
         if folder.is_self_protected:
             folder.acl = form.acl.data
         db.session.add(folder)
         logger.info('Folder %s created by %s', folder, session.user)
         signals.attachments.folder_created.send(folder, user=session.user)
         flash(_("Folder \"{name}\" created").format(name=folder.title), 'success')
         return jsonify_data(attachment_list=_render_attachment_list(self.object))
     return jsonify_template('attachments/create_folder.html', form=form,
                             protection_message=_render_protection_message(self.object))
開發者ID:fph,項目名稱:indico,代碼行數:16,代碼來源:base.py


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