def _create(self): """ Creates the Vidyo public room that will be associated to this CSBooking, based on the booking params. After creation, it also retrieves some more information from the newly created room. Returns None if success. Returns a VidyoError if there is a problem, such as the name being duplicated. """ result = ExternalOperationsManager.execute(self, "createRoom", VidyoOperations.createRoom, self) if isinstance(result, VidyoError): return result else: # Link to a Session or Contribution if requested self._roomId = str( result.roomID ) #we need to convert values read to str or there will be a ZODB exception self._extension = str(result.extension) self._url = str(result.RoomMode.roomURL) self.setOwnerAccount(str(result.ownerName)) self.setBookingOK() VidyoTools.getEventEndDateIndex().indexBooking(self) VidyoTools.getIndexByVidyoRoom().indexBooking(self) self._setAutomute()
def _attach(self): """ Creates the Vidyo public room that will be associated to this CSBooking, based on the booking params. Returns None if success. Returns a VidyoError if there is a problem. """ result = ExternalOperationsManager.execute(self, "attachRoom", VidyoOperations.attachRoom, self) if isinstance(result, VidyoError): return result else: self._roomId = str(result.roomID) self._extension = str(result.extension) self._url = str(result.RoomMode.roomURL) self.setOwnerAccount(str(result.ownerName), updateAvatar=True) recoveredDescription = VidyoTools.recoverVidyoDescription( result.description) if recoveredDescription: self._bookingParams["roomDescription"] = recoveredDescription else: self._warning = "invalidDescription" if bool(result.RoomMode.hasPIN): self.setPin(str(result.RoomMode.roomPIN)) else: self.setPin("") if bool(result.RoomMode.hasModeratorPIN): self.setModeratorPin(str(result.RoomMode.moderatorPIN)) else: self.setModeratorPin("") self._bookingParams["autoMute"] = self._getAutomute() self.setBookingOK() VidyoTools.getEventEndDateIndex().indexBooking(self) VidyoTools.getIndexByVidyoRoom().indexBooking(self)
def _delete(self, fromDeleteOld=False, maxDate=None): """ Deletes the Vidyo Public room associated to this CSBooking, based on the roomId Returns None if success. If trying to delete a non existing room, there will be a message in self._warning so that it is caught by Main.js's postDelete function. """ if self.isCreated(): deleteRemote = unindexBooking = False if self.hasToBeDeleted(fromDeleteOld, maxDate): self.setCreated(False) deleteRemote = unindexBooking = True elif not fromDeleteOld: unindexBooking = True if deleteRemote: result = ExternalOperationsManager.execute( self, "deleteRoom", VidyoOperations.deleteRoom, self, self._roomId) if isinstance(result, VidyoError): if result.getErrorType( ) == "unknownRoom" and result.getOperation() == "delete": if not fromDeleteOld: self._warning = "cannotDeleteNonExistant" else: return result if unindexBooking: VidyoTools.getEventEndDateIndex().unindexBooking(self) VidyoTools.getIndexByVidyoRoom().unindexBooking(self)
def setBookingNotPresent(self): """ Changes some of the booking's attributes when the room is still in the Indico DB but not in the remote system any more. """ self._created = False # booking is not present remotely so no need to delete it later VidyoTools.getEventEndDateIndex().unindexBooking(self)
def _attach(self): """ Creates the Vidyo public room that will be associated to this CSBooking, based on the booking params. Returns None if success. Returns a VidyoError if there is a problem. """ result = ExternalOperationsManager.execute(self, "attachRoom", VidyoOperations.attachRoom, self) if isinstance(result, VidyoError): return result else: self._roomId = str(result.roomID) self._extension = str(result.extension) self._url = str(result.RoomMode.roomURL) self.setOwnerAccount(str(result.ownerName), updateAvatar = True) recoveredDescription = VidyoTools.recoverVidyoDescription(result.description) if recoveredDescription: self._bookingParams["roomDescription"] = recoveredDescription else: self._warning = "invalidDescription" if bool(result.RoomMode.hasPIN): self.setPin(str(result.RoomMode.roomPIN)) else: self.setPin("") if bool(result.RoomMode.hasModeratorPIN): self.setModeratorPin(str(result.RoomMode.moderatorPIN)) else: self.setModeratorPin("") self._bookingParams["autoMute"] = self._getAutomute() self.setBookingOK() VidyoTools.getEventEndDateIndex().indexBooking(self) VidyoTools.getIndexByVidyoRoom().indexBooking(self)
def call(self): try: maxDate = VidyoTools.getBookingsOldDate() previousTotal = VidyoTools.getEventEndDateIndex().getCount() error, attainedDate = DeleteOldRoomsAction._deleteRemoteRooms( maxDate) newTotal = VidyoTools.getEventEndDateIndex().getCount() page = WDeleteOldRoomsActionResult(maxDate, previousTotal, newTotal, error, attainedDate).getHTML() #we send the mail without ExternalOperationsManager wrapping so that we see the result of an #eventual 2nd pass (we do want to have more than 1 email, or at least the last one) #TODO: change later when emails are stored in ContextManager and sent after commit DeleteOldRoomsAction._sendResultEmail(maxDate, previousTotal, newTotal, error, attainedDate) return page except Exception: Logger.get("Vidyo").exception( "Exception during Vidyo's DeleteOldRoomsAction call") raise
def _delete(self, fromDeleteOld = False, maxDate = None): """ Deletes the Vidyo Public room associated to this CSBooking, based on the roomId Returns None if success. If trying to delete a non existing room, there will be a message in self._warning so that it is caught by Main.js's postDelete function. """ if self.isCreated(): deleteRemote = unindexBooking = False if self.hasToBeDeleted(fromDeleteOld, maxDate): self.setCreated(False) deleteRemote = unindexBooking = True elif not fromDeleteOld: unindexBooking = True if deleteRemote: result = ExternalOperationsManager.execute(self, "deleteRoom", VidyoOperations.deleteRoom, self, self._roomId) if isinstance(result, VidyoError): if result.getErrorType() == "unknownRoom" and result.getOperation() == "delete": if not fromDeleteOld: self._warning = "cannotDeleteNonExistant" else: return result if unindexBooking: VidyoTools.getEventEndDateIndex().unindexBooking(self) VidyoTools.getIndexByVidyoRoom().unindexBooking(self)
def setBookingNotPresent(self): """ Changes some of the booking's attributes when the room is still in the Indico DB but not in the remote system any more. """ self._created = False #booking is not present remotely so no need to delete it later VidyoTools.getEventEndDateIndex().unindexBooking(self) for booking in VidyoTools.getIndexByVidyoRoom().getBookingList( self.getRoomId()): VidyoTools.getIndexByVidyoRoom().unindexBooking(booking) booking.setCreated(False)
def getVars(self): variables = WCSPageTemplateBase.getVars(self) variables["MaxDate"] = self._maxDate variables["TotalRoomCount"] = VidyoTools.getEventEndDateIndex().getCount() oldBookingsPerConfIterator = VidyoTools.getEventEndDateIndex().iterBookingsPerConf(maxDate = self._maxDate) newBookingsPerConfIterator = VidyoTools.getEventEndDateIndex().iterBookingsPerConf(minDate = self._maxDate + timedelta(seconds = 1)) variables["OldBookings"] = WBookingsList(oldBookingsPerConfIterator).getHTML() variables["NewBookings"] = WBookingsList(newBookingsPerConfIterator).getHTML() variables["ServerTZ"] = info.HelperMaKaCInfo.getMaKaCInfoInstance().getTimezone() return variables
def cloneEvent(cls, confToClone, params): """ we'll clone only the vidyo services created by the user who is cloning the conference""" conf = params['conf'] options = params['options'] if options.get("vidyo", True): for vs in confToClone.getCSBookingManager().getBookingList(filterByType="Vidyo"): # Do not cloning the booking when were are NOT cloning the timetable (optionas has sessions and contribs) # and the booking is linked to a contrib/session if (options.get('sessions', False) and options.get('contributions', False)) or not vs.hasSessionOrContributionLink(): newBooking = vs.clone(conf) conf.getCSBookingManager().addBooking(newBooking) VidyoTools.getIndexByVidyoRoom().indexBooking(newBooking) VidyoTools.getEventEndDateIndex().indexBooking(newBooking)
def cloneEvent(cls, confToClone, params): """ we'll clone only the vidyo services created by the user who is cloning the conference""" conf = params['conf'] options = params['options'] if options.get("vidyo", True): for vs in Catalog.getIdx("cs_bookingmanager_conference").get(confToClone.getId()).getBookingList(filterByType="Vidyo"): # Do not cloning the booking when were are NOT cloning the timetable (optionas has sessions and contribs) # and the booking is linked to a contrib/session if (options.get('sessions', False) and options.get('contributions', False)) or not vs.hasSessionOrContributionLink(): newBooking = vs.clone(conf) Catalog.getIdx("cs_bookingmanager_conference").get(conf.getId()).addBooking(newBooking) VidyoTools.getIndexByVidyoRoom().indexBooking(newBooking) VidyoTools.getEventEndDateIndex().indexBooking(newBooking)
def _create(self): """ Creates the Vidyo public room that will be associated to this CSBooking, based on the booking params. After creation, it also retrieves some more information from the newly created room. Returns None if success. Returns a VidyoError if there is a problem, such as the name being duplicated. """ result = ExternalOperationsManager.execute(self, "createRoom", VidyoOperations.createRoom, self) if isinstance(result, VidyoError): return result else: # Link to a Session or Contribution if requested self._roomId = str(result.roomID) # we need to convert values read to str or there will be a ZODB exception self._extension = str(result.extension) self._url = str(result.RoomMode.roomURL) self.setOwnerAccount(str(result.ownerName)) self.setBookingOK() VidyoTools.getEventEndDateIndex().indexBooking(self)
def getVars(self): variables = WCSPageTemplateBase.getVars(self) variables["MaxDate"] = self._maxDate variables["TotalRoomCount"] = VidyoTools.getEventEndDateIndex( ).getCount() oldBookingsPerConfIterator = VidyoTools.getEventEndDateIndex( ).iterbookings(maxDate=self._maxDate) newBookingsPerConfIterator = VidyoTools.getEventEndDateIndex( ).iterbookings(minDate=self._maxDate + timedelta(seconds=1)) oldBookingsPerConf, newBookingsPerConf = self._postProcessingClones( oldBookingsPerConfIterator, newBookingsPerConfIterator) variables["OldBookings"] = WBookingsList(oldBookingsPerConf).getHTML() variables["NewBookings"] = WBookingsList(newBookingsPerConf).getHTML() variables["ServerTZ"] = info.HelperMaKaCInfo.getMaKaCInfoInstance( ).getTimezone() return variables
def call(self): try: maxDate = VidyoTools.getBookingsOldDate() previousTotal = VidyoTools.getEventEndDateIndex().getCount() error, attainedDate = DeleteOldRoomsAction._deleteRemoteRooms(maxDate) newTotal = VidyoTools.getEventEndDateIndex().getCount() page = WDeleteOldRoomsActionResult(maxDate, previousTotal, newTotal, error, attainedDate).getHTML() #we send the mail without ExternalOperationsManager wrapping so that we see the result of an #eventual 2nd pass (we do want to have more than 1 email, or at least the last one) #TODO: change later when emails are stored in ContextManager and sent after commit DeleteOldRoomsAction._sendResultEmail(maxDate, previousTotal, newTotal, error, attainedDate) return page except Exception: Logger.get("Vidyo").exception("Exception during Vidyo's DeleteOldRoomsAction call") raise
def _deleteRemoteRooms(cls, maxDate): """ Deletes the remote rooms from Vidyo Ignores if a room does not exist (because booking._delete does not return VidyoError in that case). Stops in any other error / exception and returns the error cause and attainedDate- booking._delete will execute the remote deletion for 1 room wrapped with ExternalOperationsManager """ error = False attainedDate = None try: for booking in list(VidyoTools.getEventEndDateIndex().iterbookings(maxDate = maxDate)): result = booking._delete(fromDeleteOld = True, maxDate = maxDate) if isinstance(result, VidyoError): error = result attainedDate = booking.getConference().getAdjustedEndDate(tz = 'UTC') break except Exception, e: error = e attainedDate = booking.getConference().getAdjustedEndDate(tz = 'UTC')
def __init__(self, booking): VidyoAdminNotificationBase.__init__(self, booking) currentCount = VidyoTools.getEventEndDateIndex().getCount() self.setSubject("""[Vidyo] Too many public rooms (%s)""" % str(currentCount)) self.setBody("""Dear Vidyo Manager,<br /> <br /> There are currently %s Vidyo public rooms created by Indico in <a href="%s">%s</a>.<br /> The system was setup to send you a notification if this number was more than %s.<br /> Please go to the <a href="%s">Vidyo Plugin configuration</a> in the Server Admin interface and press the "Clean old rooms" button.<br /> """ % (str(currentCount), MailTools.getServerName(), MailTools.getServerName(), getVidyoOptionValue("cleanWarningAmount"), str( urlHandlers.UHAdminPlugins.getURL( CollaborationTools.getCollaborationPluginType()))))
def __init__(self, booking): VidyoAdminNotificationBase.__init__(self, booking) currentCount = VidyoTools.getEventEndDateIndex().getCount() self.setSubject("""[Vidyo] Too many public rooms (%s)""" % str(currentCount)) self.setBody("""Dear Vidyo Manager,<br /> <br /> There are currently %s Vidyo public rooms created by Indico in <a href="%s">%s</a>.<br /> The system was setup to send you a notification if this number was more than %s.<br /> Please go to the <a href="%s">Vidyo Plugin configuration</a> in the Server Admin interface and press the "Clean old rooms" button.<br /> """ % (str(currentCount), MailTools.getServerName(), MailTools.getServerName(), getVidyoOptionValue("cleanWarningAmount"), str(urlHandlers.UHAdminPlugins.getURL(CollaborationTools.getCollaborationPluginType()))))
def _deleteRemoteRooms(cls, maxDate): """ Deletes the remote rooms from Vidyo Ignores if a room does not exist (because booking._delete does not return VidyoError in that case). Stops in any other error / exception and returns the error cause and attainedDate- booking._delete will execute the remote deletion for 1 room wrapped with ExternalOperationsManager """ error = False attainedDate = None try: for booking in VidyoTools.getEventEndDateIndex().iterbookings( maxDate=maxDate): result = booking._delete(fromDeleteOld=True) if isinstance(result, VidyoError): error = result attainedDate = booking.getConference().getAdjustedEndDate( tz='UTC') break except Exception, e: error = e attainedDate = booking.getConference().getAdjustedEndDate(tz='UTC')
def notifyEventDateChanges(self, oldStartDate, newStartDate, oldEndDate, newEndDate): """ Moves the booking in the old bookings index """ if oldEndDate is not None: VidyoTools.getEventEndDateIndex().moveBooking(self, oldEndDate)
def conferenceMigration1_0(dbi, withRBDB, prevVersion): """ Tasks: 1. Moving support info fields from conference to a dedicated class 2. Update non inherited children list 3. Update Vidyo indexes """ def _updateMaterial(obj): for material in obj.getAllMaterialList(sort=False): material.getAccessController().setNonInheritingChildren(set()) if material.getAccessController().getAccessProtectionLevel() != 0: material.notify_protection_to_owner(material) for resource in material.getResourceList(sort=False): if resource.getAccessController().getAccessProtectionLevel() != 0: resource.notify_protection_to_owner() def updateSupport(conf): ################################################################# #Moving support info fields from conference to a dedicated class: ################################################################# dMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(conf) caption = email = telephone = "" if hasattr(dMgr, "_supportEmailCaption"): caption = dMgr._supportEmailCaption del dMgr._supportEmailCaption if hasattr(conf, "_supportEmail"): email = conf._supportEmail del conf._supportEmail supportInfo = SupportInfo(conf, caption, email, telephone) conf.setSupportInfo(supportInfo) def updateNonInheritedChildren (conf): #################################### #Update non inherited children list: #################################### conf.getAccessController().setNonInheritingChildren(set()) _updateMaterial(conf) for session in conf.getSessionList(): session.getAccessController().setNonInheritingChildren(set()) if session.getAccessController().getAccessProtectionLevel() != 0: session.notify_protection_to_owner(session) _updateMaterial(session) for contrib in conf.getContributionList(): contrib.getAccessController().setNonInheritingChildren(set()) if contrib.getAccessController().getAccessProtectionLevel() != 0: contrib.notify_protection_to_owner(contrib) _updateMaterial(contrib) for subContrib in contrib.getSubContributionList(): _updateMaterial(subContrib) def updateVidyoIndex(conf, endDateIndex, vidyoRoomIndex): #################################### #Update vidyo indexes: #################################### csbm = getattr(conf, "_CSBookingManager", None) if csbm is None: return for booking in csbm.getBookingList(): if booking.getType() == "Vidyo" and booking.isCreated(): endDateIndex.indexBooking(booking) vidyoRoomIndex.indexBooking(booking) ph = PluginsHolder() collaboration_pt = ph.getPluginType("Collaboration") vidyoPluginActive = collaboration_pt.isActive() and collaboration_pt.getPlugin("Vidyo").isActive() if vidyoPluginActive: endDateIndex = VidyoTools.getEventEndDateIndex() vidyoRoomIndex = VidyoTools.getIndexByVidyoRoom() endDateIndex.clear() vidyoRoomIndex.clear() ch = ConferenceHolder() i = 0 for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'): updateSupport(conf) updateNonInheritedChildren(conf) if vidyoPluginActive: updateVidyoIndex(conf, endDateIndex, vidyoRoomIndex) if i % 10000 == 9999: dbi.commit() i += 1 dbi.commit()
def call(self): VidyoTools.getEventEndDateIndex().clear()
def call(self): VidyoTools.getEventEndDateIndex().clear()
def conferenceMigration1_0(dbi, withRBDB, prevVersion): """ Tasks: 1. Moving support info fields from conference to a dedicated class 2. Update non inherited children list 3. Update Vidyo indexes """ def _updateMaterial(obj): for material in obj.getAllMaterialList(sort=False): material.getAccessController().setNonInheritingChildren(set()) if material.getAccessController().getAccessProtectionLevel() != 0: material.notify_protection_to_owner(material) for resource in material.getResourceList(sort=False): if resource.getAccessController().getAccessProtectionLevel() != 0: resource.notify_protection_to_owner() def updateSupport(conf): ################################################################# #Moving support info fields from conference to a dedicated class: ################################################################# dMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(conf) caption = email = telephone = "" if hasattr(dMgr, "_supportEmailCaption"): caption = dMgr._supportEmailCaption del dMgr._supportEmailCaption if hasattr(conf, "_supportEmail"): email = conf._supportEmail del conf._supportEmail supportInfo = SupportInfo(conf, caption, email, telephone) conf.setSupportInfo(supportInfo) def updateNonInheritedChildren (conf): #################################### #Update non inherited children list: #################################### conf.getAccessController().setNonInheritingChildren(set()) _updateMaterial(conf) for session in conf.getSessionList(): session.getAccessController().setNonInheritingChildren(set()) if session.getAccessController().getAccessProtectionLevel() != 0: session.notify_protection_to_owner(session) _updateMaterial(session) for contrib in conf.getContributionList(): contrib.getAccessController().setNonInheritingChildren(set()) if contrib.getAccessController().getAccessProtectionLevel() != 0: contrib.notify_protection_to_owner(contrib) _updateMaterial(contrib) for subContrib in contrib.getSubContributionList(): _updateMaterial(subContrib) def updateVidyoIndex(conf, endDateIndex, vidyoRoomIndex, pluginActive): ###################### #Update Vidyo indexes: ###################### if not pluginActive: return csbm = conf.getCSBookingManager() for booking in csbm.getBookingList(): if booking.getType() == "Vidyo" and booking.isCreated(): endDateIndex.indexBooking(booking) vidyoRoomIndex.indexBooking(booking) endDateIndex = VidyoTools.getEventEndDateIndex() vidyoRoomIndex = VidyoTools.getIndexByVidyoRoom() endDateIndex.clear() vidyoRoomIndex.clear() ph = PluginsHolder() collaboration_pt = ph.getPluginType("Collaboration") pluginActive = collaboration_pt.isActive() and collaboration_pt.getPlugin("Vidyo").isActive() ch = ConferenceHolder() i = 0 for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'): updateSupport(conf) updateNonInheritedChildren(conf) updateVidyoIndex(conf, endDateIndex, vidyoRoomIndex, pluginActive) if i % 10000 == 9999: dbi.commit() i += 1 dbi.commit()
def notifyEventDateChanges(self, oldStartDate, newStartDate, oldEndDate, newEndDate): """ Moves the booking in the old bookings index """ VidyoTools.getEventEndDateIndex().moveBooking(self, oldEndDate)