本文整理汇总了Python中indico.modules.vc.models.vc_rooms.VCRoomEventAssociation.find方法的典型用法代码示例。如果您正苦于以下问题:Python VCRoomEventAssociation.find方法的具体用法?Python VCRoomEventAssociation.find怎么用?Python VCRoomEventAssociation.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.vc.models.vc_rooms.VCRoomEventAssociation
的用法示例。
在下文中一共展示了VCRoomEventAssociation.find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_vc_room_association
# 需要导入模块: from indico.modules.vc.models.vc_rooms import VCRoomEventAssociation [as 别名]
# 或者: from indico.modules.vc.models.vc_rooms.VCRoomEventAssociation import find [as 别名]
def process_vc_room_association(plugin, event, vc_room, form, event_vc_room=None, allow_same_room=False):
# disable autoflush, so that the new event_vc_room does not influence the result
with db.session.no_autoflush:
if event_vc_room is None:
event_vc_room = VCRoomEventAssociation()
plugin.update_data_association(event, vc_room, event_vc_room, form.data)
existing = set()
if event_vc_room.link_object is not None:
# check whether there is a room-event association already present
# for the given event, room and plugin
q = VCRoomEventAssociation.find(
VCRoomEventAssociation.event_new == event,
VCRoomEventAssociation.link_object == event_vc_room.link_object,
_join=VCRoom
)
if allow_same_room:
q = q.filter(VCRoom.id != vc_room.id)
existing = {x.vc_room for x in q}
if event_vc_room.link_type != VCRoomLinkType.event and existing:
transaction.abort()
flash(_("There is already a VC room attached to '{link_object_title}'.").format(
link_object_title=resolve_title(event_vc_room.link_object)), 'error')
return None
elif event_vc_room.link_type == VCRoomLinkType.event and vc_room in existing:
transaction.abort()
flash(_("This {plugin_name} room is already attached to the event.").format(plugin_name=plugin.friendly_name),
'error')
return None
else:
return event_vc_room
示例2: find_event_vc_rooms
# 需要导入模块: from indico.modules.vc.models.vc_rooms import VCRoomEventAssociation [as 别名]
# 或者: from indico.modules.vc.models.vc_rooms.VCRoomEventAssociation import find [as 别名]
def find_event_vc_rooms(from_dt=None, to_dt=None, distinct=False):
"""Finds VC rooms matching certain criteria
:param from_dt: earliest event/contribution to include
:param to_dt: latest event/contribution to include
:param distinct: if True, never return the same ``(event, vcroom)``
more than once (even if it's linked more than once to
that event)
"""
from indico.modules.vc.models.vc_rooms import VCRoomEventAssociation
query = VCRoomEventAssociation.find()
if distinct:
query = query.distinct(VCRoomEventAssociation.event_id, VCRoomEventAssociation.vc_room_id)
if from_dt is not None or to_dt is not None:
query = query.join(IndexedEvent, IndexedEvent.id == VCRoomEventAssociation.event_id)
if from_dt is not None:
query = query.filter(IndexedEvent.start_date >= from_dt)
if to_dt is not None:
query = query.filter(IndexedEvent.start_date < to_dt)
for vc_room in query:
yield vc_room