本文整理汇总了Python中indico.modules.attachments.models.folders.AttachmentFolder.find_first方法的典型用法代码示例。如果您正苦于以下问题:Python AttachmentFolder.find_first方法的具体用法?Python AttachmentFolder.find_first怎么用?Python AttachmentFolder.find_first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.attachments.models.folders.AttachmentFolder
的用法示例。
在下文中一共展示了AttachmentFolder.find_first方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_material
# 需要导入模块: from indico.modules.attachments.models.folders import AttachmentFolder [as 别名]
# 或者: from indico.modules.attachments.models.folders.AttachmentFolder import find_first [as 别名]
def _create_material(self, logs):
folder = AttachmentFolder.find_first(object=self.event_new, is_default=False, title='Chat Logs',
is_deleted=False)
if folder is None:
folder = AttachmentFolder(protection_mode=ProtectionMode.protected, linked_object=self.event_new,
title='Chat Logs', description='Chat logs for this event')
db.session.add(folder)
filename = '{}.html'.format(secure_filename(self.material_name, 'logs'))
attachment = Attachment(folder=folder, user=session.user, title=self.material_name, type=AttachmentType.file,
description="Chat logs for the chat room '{}'".format(self.chatroom.name))
attachment.file = AttachmentFile(user=session.user, filename=filename, content_type='text/html')
attachment.file.save(logs.encode('utf-8'))
db.session.flush()
signals.attachments.attachment_created.send(attachment, user=session.user)
log_data = [
('Range', 'Everything' if not self.date_filter else
'{} - {}'.format(format_date(self.start_date), format_date(self.end_date))),
]
self.event.log(EventLogRealm.management, EventLogKind.positive, 'Chat',
'Created material: {}'.format(filename), session.user, data=log_data)