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
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) # check whether there is a room-event association already present # for the given event, room and plugin q = VCRoomEventAssociation.find( VCRoomEventAssociation.event_id == event.id, VCRoomEventAssociation.link_type == event_vc_room.link_type, VCRoomEventAssociation.link_id == event_vc_room.link_id, _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
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
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 == db.cast(VCRoomEventAssociation.event_id, db.String)) 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