本文整理汇总了Python中indico.modules.attachments.models.attachments.Attachment.acl方法的典型用法代码示例。如果您正苦于以下问题:Python Attachment.acl方法的具体用法?Python Attachment.acl怎么用?Python Attachment.acl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.attachments.models.attachments.Attachment
的用法示例。
在下文中一共展示了Attachment.acl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_attachment_link
# 需要导入模块: from indico.modules.attachments.models.attachments import Attachment [as 别名]
# 或者: from indico.modules.attachments.models.attachments.Attachment import acl [as 别名]
def add_attachment_link(data, linked_object):
"""Add a link attachment to linked_object"""
folder = data.pop('folder', None)
if not folder:
folder = AttachmentFolder.get_or_create_default(linked_object=linked_object)
assert folder.object == linked_object
link = Attachment(user=session.user, type=AttachmentType.link, folder=folder)
link.populate_from_dict(data, skip={'acl', 'protected'})
if link.is_self_protected:
link.acl = data['acl']
db.session.flush()
logger.info('Attachment %s added by %s', link, session.user)
signals.attachments.attachment_created.send(link, user=session.user)
示例2: _process
# 需要导入模块: from indico.modules.attachments.models.attachments import Attachment [as 别名]
# 或者: from indico.modules.attachments.models.attachments.Attachment import acl [as 别名]
def _process(self):
form = AddAttachmentLinkForm(linked_object=self.object)
if form.validate_on_submit():
folder = form.folder.data or AttachmentFolder.get_or_create_default(linked_object=self.object)
link = Attachment(user=session.user, type=AttachmentType.link)
form.populate_obj(link, skip={'acl'})
if link.is_protected:
link.acl = form.acl.data
link.folder = folder
db.session.flush()
logger.info('Attachment {} added by {}'.format(link, session.user))
signals.attachments.attachment_created.send(link, user=session.user)
flash(_("The link has been added"), 'success')
return jsonify_data(attachment_list=_render_attachment_list(self.object))
return jsonify_template('attachments/add_link.html', form=form,
protection_message=_render_protection_message(self.object),
folders_protection_info=_get_folders_protection_info(self.object))
示例3: _process
# 需要导入模块: from indico.modules.attachments.models.attachments import Attachment [as 别名]
# 或者: from indico.modules.attachments.models.attachments.Attachment import acl [as 别名]
def _process(self):
form = AddAttachmentFilesForm(linked_object=self.object)
if form.validate_on_submit():
files = request.files.getlist('file')
folder = form.folder.data or AttachmentFolder.get_or_create_default(linked_object=self.object)
for f in files:
filename = secure_filename(f.filename, 'attachment')
attachment = Attachment(folder=folder, user=session.user, title=to_unicode(f.filename),
type=AttachmentType.file, protection_mode=form.protection_mode.data)
if attachment.is_self_protected:
attachment.acl = form.acl.data
content_type = mimetypes.guess_type(f.filename)[0] or f.mimetype or 'application/octet-stream'
attachment.file = AttachmentFile(user=session.user, filename=filename, content_type=content_type)
attachment.file.save(f.file)
db.session.add(attachment)
db.session.flush()
logger.info('Attachment %s uploaded by %s', attachment, session.user)
signals.attachments.attachment_created.send(attachment, user=session.user)
flash(ngettext("The attachment has been uploaded", "{count} attachments have been uploaded", len(files))
.format(count=len(files)), 'success')
return jsonify_data(attachment_list=_render_attachment_list(self.object))
return jsonify_template('attachments/upload.html', form=form, action=url_for('.upload', self.object),
protection_message=_render_protection_message(self.object),
folders_protection_info=_get_folders_protection_info(self.object))