def clone(self, new_event, options): if 'vc_rooms' not in options: return for old_event_vc_room in VCRoomEventAssociation.find_for_event(self.event, include_hidden=True): event_vc_room = VCRoomEventAssociation(event_id=int(new_event.id), link_type=old_event_vc_room.link_type, link_id=old_event_vc_room.link_id, show=old_event_vc_room.show, data=old_event_vc_room.data) if event_vc_room.link_object is not None: event_vc_room.vc_room = old_event_vc_room.vc_room db.session.add(event_vc_room)
def migrate_event_booking(self, vc_room, booking): ch_idx = self.zodb_root['conferences'] booking_params = booking._bookingParams old_link_type = getattr(booking, '_linkVideoType', None) link_type = (VCRoomLinkType.get(MAP_LINK_TYPES[booking._linkVideoType]) if old_link_type else VCRoomLinkType.event) if booking._conf.id not in ch_idx: print cformat( "[%{red!}WARNING%{reset}] %{yellow!}{} is linked to event '{}' but the latter seems to have been" " deleted. Removing link." ).format(vc_room, booking._conf.id) return if link_type == VCRoomLinkType.event: extracted_id = None elif not booking._linkVideoId: print cformat( "[%{red!}WARNING%{reset}] %{yellow!}{} is linked to a {} but no id given%{reset}. Linking to event." ).format(vc_room, link_type.name) extracted_id = None link_type = VCRoomLinkType.event else: extracted_id = extract_id(booking._linkVideoId) if link_type != VCRoomLinkType.event and not is_valid_link(booking._conf, link_type, extracted_id): print cformat( "[%{red!}WARNING%{reset}] %{yellow!}{} is linked to a {} but it does not exist%{reset}. " "Linking to event." ).format(vc_room, link_type.name) link_type = VCRoomLinkType.event extracted_id = None event_vc_room = VCRoomEventAssociation( event_id=booking._conf.id, vc_room=vc_room, link_type=link_type, link_id=extracted_id, show=not booking._hidden ) event_vc_room.data = { 'show_pin': booking_params['displayPin'], 'show_phone_numbers': booking_params.get('displayPhoneNumbers', True), 'show_autojoin': booking_params['displayURL'], } db.session.add(event_vc_room) print cformat('%{green}<->%{reset} %{cyan!}{}%{reset} %{red!}{}%{reset} [%{yellow}{}%{reset}]').format( booking._conf.id, booking._roomId, old_link_type)
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 _session_slot_deleted(session_slot, **kwargs): event = session_slot.getConference() if event.has_legacy_id: return for event_vc_room in VCRoomEventAssociation.find_for_event(event, include_hidden=True, include_deleted=True): if event_vc_room.link_object is None: event_vc_room.link_type = VCRoomLinkType.event event_vc_room.link_id = None
def _contrib_deleted(contrib, **kwargs): event = contrib.getConference() if not event.id.isdigit(): return for event_vc_room in VCRoomEventAssociation.find_for_event(event, include_hidden=True, include_deleted=True): if event_vc_room.link_object is None: event_vc_room.link_type = VCRoomLinkType.event event_vc_room.link_id = None
def _process(self): try: room_event_assocs = VCRoomEventAssociation.find_for_event(self._conf, include_hidden=True, include_deleted=True).all() except ValueError: raise IndicoError(_('This page is not available for legacy events.')) event_vc_rooms = [event_vc_room for event_vc_room in room_event_assocs if event_vc_room.vc_room.plugin] return WPVCManageEvent.render_template('manage_event.html', self._conf, event=self._conf, event_vc_rooms=event_vc_rooms, plugins=get_vc_plugins().values())
def _process(self): event_vc_rooms = VCRoomEventAssociation.find_for_event(self.event_new).all() vc_plugins_available = bool(get_vc_plugins()) linked_to = defaultdict(lambda: defaultdict(list)) for event_vc_room in event_vc_rooms: if event_vc_room.vc_room.plugin: linked_to[event_vc_room.link_type.name][event_vc_room.link_object].append(event_vc_room) return WPVCEventPage.render_template('event_vc.html', self._conf, event=self.event_new, event_vc_rooms=event_vc_rooms, linked_to=linked_to, vc_plugins_available=vc_plugins_available)
def clone_room(self, old_event_vc_room, link_object): """Clone the room, returning a new :class:`VCRoomEventAssociation`. :param old_event_vc_room: the original :class:`VCRoomEventAssociation` :param link_object: the new object the association will be tied to :return: the new :class:`VCRoomEventAssociation` """ return VCRoomEventAssociation(show=old_event_vc_room.show, data=old_event_vc_room.data, link_object=link_object)
def _process(self): event_vc_rooms = VCRoomEventAssociation.find_for_event(self._conf).all() vc_plugins_available = True if get_vc_plugins() else False linked_to = defaultdict(lambda: defaultdict(list)) for event_vc_room in event_vc_rooms: if event_vc_room.vc_room.plugin: linked_to[event_vc_room.link_type.name][event_vc_room.link_object].append(event_vc_room) return WPVCEventPage.render_template('event_vc.html', self._conf, event=self._conf, event_vc_rooms=event_vc_rooms, linked_to=linked_to, vc_plugins_available=vc_plugins_available)
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 _inject_event_header(event, **kwargs): res = VCRoomEventAssociation.find_for_event(event, only_linked_to_event=True) event_vc_rooms = [ event_vc_room for event_vc_room in res.all() if event_vc_room.vc_room.plugin is not None ] if event_vc_rooms: return render_template('vc/event_header.html', event=event, event_vc_rooms=event_vc_rooms)
def _process(self): event_vc_rooms = [event_vc_room for event_vc_room in VCRoomEventAssociation.find_for_event(self.event).all() if event_vc_room.vc_room.plugin] vc_plugins_available = bool(get_vc_plugins()) linked_to = defaultdict(lambda: defaultdict(list)) for event_vc_room in event_vc_rooms: linked_to[event_vc_room.link_type.name][event_vc_room.link_object].append(event_vc_room) return WPVCEventPage.render_template('event_vc.html', self.event, event_vc_rooms=event_vc_rooms, linked_to=linked_to, vc_plugins_available=vc_plugins_available)
def _inject_vc_room_action_buttons(event, item, **kwargs): event_vc_room = VCRoomEventAssociation.get_linked_for_event(event).get( item) if event_vc_room and event_vc_room.vc_room.plugin: plugin = event_vc_room.vc_room.plugin name = get_overridable_template_name('vc_room_timetable_buttons.html', plugin, core_prefix='vc/') return render_template(name, event=event, event_vc_room=event_vc_room, **kwargs)
def _process(self): room_event_assocs = VCRoomEventAssociation.find_for_event( self.event, include_hidden=True, include_deleted=True).all() event_vc_rooms = [ event_vc_room for event_vc_room in room_event_assocs if event_vc_room.vc_room.plugin ] return WPVCManageEvent.render_template( 'manage_event.html', self.event, event_vc_rooms=event_vc_rooms, plugins=get_vc_plugins().values())
def _process(self): room_event_assocs = VCRoomEventAssociation.find_for_event( self.event_new, include_hidden=True, include_deleted=True ).all() event_vc_rooms = [event_vc_room for event_vc_room in room_event_assocs if event_vc_room.vc_room.plugin] return WPVCManageEvent.render_template( "manage_event.html", self._conf, event=self.event_new, event_vc_rooms=event_vc_rooms, plugins=get_vc_plugins().values(), )
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
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 _process_args(self): id_ = request.view_args['event_vc_room_id'] self.event_vc_room = VCRoomEventAssociation.find_one(id=id_) if not self.event_vc_room: raise NotFound( _("Event VC Room not found for id {id}").format(id=id_)) if not self.event_vc_room.link_object: raise IndicoError( _("Event VC Room ({id}) is not linked to anything").format( id=id_)) event_id = int(request.view_args['confId']) event = self.event_vc_room.link_object.event if not event: raise IndicoError( _("Event VC Room ({id}) does not have an event").format( id=id_)) if event.id != event_id: raise IndicoError( _("Event VC Room ({id}) does not have an event with the id {conf.id}" ).format(id=id_, conf=event)) room = self.event_vc_room.link_object.room if self.event_vc_room.link_object else None if not room: raise IndicoError( _("Event VC Room ({id}) is not linked to an event with a room" ).format(id=id_)) self.room_name = room.generate_name() self.room_special_name = room.name if not self.room_name: raise IndicoError( _("Event VC Room ({id}) is not linked to an event with a valid room" ).format(id=id_)) if not self.room_special_name: self.room_special_name = self.room_name
def _create_meeting(name='New Room'): user_joe = create_user(1, email='*****@*****.**') vc_room = VCRoom(type='zoom', status=VCRoomStatus.created, name=name, created_by_id=0, data={ 'description': 'something something', 'password': '******', 'host': user_joe.identifier, 'meeting_type': 'meeting', 'mute_host_video': False, 'mute_audio': False, 'mute_participant_video': False, 'waiting_room': False }) VCRoomEventAssociation(linked_event=dummy_event, vc_room=vc_room, link_type=VCRoomLinkType.event, data={}) db.session.flush() zoom_plugin.create_room(vc_room, dummy_event) return vc_room
def _inject_event_header(event, **kwargs): res = VCRoomEventAssociation.find_for_event(event, only_linked_to_event=True) event_vc_rooms = [event_vc_room for event_vc_room in res.all() if event_vc_room.vc_room.plugin is not None] if event_vc_rooms: return render_template('vc/event_header.html', event=event, event_vc_rooms=event_vc_rooms)
def _inject_vc_room_action_buttons(event, item, **kwargs): event_vc_room = VCRoomEventAssociation.get_linked_for_event(event).get(item) if event_vc_room and event_vc_room.vc_room.plugin: return render_plugin_template('{}:vc_room_timetable_buttons.html'.format(event_vc_room.vc_room.plugin.name), event=event, event_vc_room=event_vc_room, **kwargs)
def get_options(self): enabled = bool(VCRoomEventAssociation.find_for_event(self.event, include_hidden=True).count()) return {'vc_rooms': (_('Video conference rooms'), enabled, True)}
def _visible(event): if event.has_legacy_id: return False return bool(get_vc_plugins()) and bool(VCRoomEventAssociation.find_for_event(event).count())
def _checkParams(self): self.event_vc_room = VCRoomEventAssociation.get_one( request.view_args['event_vc_room_id']) self.vc_room = self.event_vc_room.vc_room
def _event_deleted(event, **kwargs): user = session.user if has_request_context() and session.user else User.get_system_user() for event_vc_room in VCRoomEventAssociation.find_for_event(event, include_hidden=True, include_deleted=True): event_vc_room.delete(user)
def _event_deleted(event, **kwargs): if not event.id.isdigit(): return for event_vc_room in VCRoomEventAssociation.find_for_event(event, include_hidden=True, include_deleted=True): event_vc_room.delete(_get_user())
def _inject_vc_room_action_buttons(event, item, **kwargs): event_vc_room = VCRoomEventAssociation.get_linked_for_event(event).get(item) if event_vc_room and event_vc_room.vc_room.plugin: plugin = event_vc_room.vc_room.plugin name = get_overridable_template_name('vc_room_timetable_buttons.html', plugin, core_prefix='vc/') return render_template(name, event=event, event_vc_room=event_vc_room, **kwargs)
def _visible(event): return bool(get_vc_plugins()) and VCRoomEventAssociation.find_for_event(event).has_rows()
def _visible(event): return bool(get_vc_plugins()) and bool(VCRoomEventAssociation.find_for_event(event).count())
def _event_deleted(event, **kwargs): user = session.user if has_request_context() and session.user else User.get(Config.getInstance().getJanitorUserId()) for event_vc_room in VCRoomEventAssociation.find_for_event(event, include_hidden=True, include_deleted=True): event_vc_room.delete(user)
def _visible(event): if not event.id.isdigit(): return False return (bool(get_vc_plugins()) and bool(VCRoomEventAssociation.find_for_event(event, only_linked_to_event=True).count()))
def _visible(event): return bool(get_vc_plugins()) and bool( VCRoomEventAssociation.find_for_event(event).count())
def _event_deleted(event, **kwargs): user = session.user if has_request_context( ) and session.user else User.get(Config.getInstance().getJanitorUserId()) for event_vc_room in VCRoomEventAssociation.find_for_event( event, include_hidden=True, include_deleted=True): event_vc_room.delete(user)
def _process_args(self): self.event_vc_room = VCRoomEventAssociation.get_or_404(request.view_args['event_vc_room_id']) self.vc_room = self.event_vc_room.vc_room
def get_options(self): enabled = bool( VCRoomEventAssociation.find_for_event(self.event, include_hidden=True).count()) return {'vc_rooms': (_('Videoconference rooms'), enabled, True)}
def _checkParams(self): self.event_vc_room = VCRoomEventAssociation.get_one(request.view_args['event_vc_room_id']) self.vc_room = self.event_vc_room.vc_room