本文整理汇总了Python中indico.modules.events.Event.log方法的典型用法代码示例。如果您正苦于以下问题:Python Event.log方法的具体用法?Python Event.log怎么用?Python Event.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.events.Event
的用法示例。
在下文中一共展示了Event.log方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_event
# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import log [as 别名]
def create_event(category, event_type, data, add_creator_as_manager=True, features=None):
"""Create a new event.
:param category: The category in which to create the event
:param event_type: An `EventType` value
:param data: A dict containing data used to populate the event
:param add_creator_as_manager: Whether the creator (current user)
should be added as a manager
:param features: A list of features that will be enabled for the
event. If set, only those features will be used
and the default feature set for the event type
will be ignored.
"""
event = Event(category=category, type_=event_type)
data.setdefault('creator', session.user)
theme = data.pop('theme', None)
person_link_data = data.pop('person_link_data', {})
event.populate_from_dict(data)
db.session.flush()
event.person_link_data = person_link_data
if theme is not None:
layout_settings.set(event, 'timetable_theme', theme)
if add_creator_as_manager:
with event.logging_disabled:
event.update_principal(event.creator, full_access=True)
if features is not None:
features_event_settings.set(event, 'enabled', features)
db.session.flush()
signals.event.created.send(event)
logger.info('Event %r created in %r by %r ', event, category, session.user)
event.log(EventLogRealm.event, EventLogKind.positive, 'Event', 'Event created', session.user)
db.session.flush()
return event
示例2: create_event
# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import log [as 别名]
def create_event(category, event_type, data, add_creator_as_manager=True, features=None):
from indico.modules.rb_new.operations.bookings import create_booking_for_event
"""Create a new event.
:param category: The category in which to create the event
:param event_type: An `EventType` value
:param data: A dict containing data used to populate the event
:param add_creator_as_manager: Whether the creator (current user)
should be added as a manager
:param features: A list of features that will be enabled for the
event. If set, only those features will be used
and the default feature set for the event type
will be ignored.
"""
event = Event(category=category, type_=event_type)
data.setdefault('creator', session.user)
theme = data.pop('theme', None)
create_booking = data.pop('create_booking', False)
person_link_data = data.pop('person_link_data', {})
event.populate_from_dict(data)
db.session.flush()
event.person_link_data = person_link_data
if theme is not None:
layout_settings.set(event, 'timetable_theme', theme)
if add_creator_as_manager:
with event.logging_disabled:
event.update_principal(event.creator, full_access=True)
if features is not None:
features_event_settings.set(event, 'enabled', features)
db.session.flush()
signals.event.created.send(event)
logger.info('Event %r created in %r by %r ', event, category, session.user)
event.log(EventLogRealm.event, EventLogKind.positive, 'Event', 'Event created', session.user)
db.session.flush()
if create_booking:
room_id = data['location_data'].pop('room_id', None)
if room_id:
booking = create_booking_for_event(room_id, event)
if booking:
logger.info('Booking %r created for event %r', booking, event)
log_data = {'Room': booking.room.full_name,
'Date': booking.start_dt.strftime('%d/%m/%Y'),
'Times': '%s - %s' % (booking.start_dt.strftime('%H:%M'), booking.end_dt.strftime('%H:%M'))}
event.log(EventLogRealm.event, EventLogKind.positive, 'Event', 'Room booked for the event',
session.user, data=log_data)
db.session.flush()
return event