本文整理汇总了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()
示例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))