def hasRights(request=None, user = None, pluginName=""): """ Returns True if the logged in user is an authorised user to create bookings. This is true if: - The user is in the list of authorised user and groups request: an RH or Service object pluginName: the plugin to check """ if not PluginsHolder().hasPluginType("Collaboration"): return False if user is None: if request is None: return False else: user = request._getUser() if user: collaborationPluginType = CollaborationTools.getCollaborationPluginType() plugin = collaborationPluginType.getPlugin(pluginName) if plugin.hasOption("AuthorisedUsersGroups"): if plugin.getOption("AuthorisedUsersGroups").getValue(): for entity in plugin.getOption("AuthorisedUsersGroups").getValue(): if isinstance(entity, Group) and entity.containsUser(user) or \ isinstance(entity, Avatar) and entity == user: return True return False else: return True else: return True return False
def hasRights(request = None, user = None, plugins = []): """ Returns True if the user is an admin of one of the plugins corresponding to pluginNames plugins: a list of Plugin objects (e.g. EVO, RecordingRequest) or strings with the plugin name ('EVO', 'RecordingRequest') or the string 'any' (we will then check if the user is manager of any plugin), """ if not PluginsHolder().hasPluginType("Collaboration"): return False if user is None: if request is None: return False else: user = request._getUser() if user: collaborationPluginType = CollaborationTools.getCollaborationPluginType() plist = collaborationPluginType.getPluginList() \ if plugins == 'any' else plugins if plist: for plugin in plist: if not isinstance(plugin, Plugin): plugin = collaborationPluginType.getPlugin(plugin) if user in plugin.getOption('admins').getValue(): return True return False
def hasRights(request=None, user=None, pluginName=""): """ Returns True if the logged in user is an authorised user to create bookings. This is true if: - The user is in the list of authorised user and groups request: an RH or Service object pluginName: the plugin to check """ if not PluginsHolder().hasPluginType("Collaboration"): return False if user is None: if request is None: return False else: user = request._getUser() if user: collaborationPluginType = CollaborationTools.getCollaborationPluginType( ) plugin = collaborationPluginType.getPlugin(pluginName) if plugin.hasOption("AuthorisedUsersGroups"): if plugin.getOption("AuthorisedUsersGroups").getValue(): for entity in plugin.getOption( "AuthorisedUsersGroups").getValue(): if isinstance(entity, Group) and entity.containsUser(user) or \ isinstance(entity, Avatar) and entity == user: return True return False else: return True else: return True return False
def hasRights(request=None, user=None, plugins=[]): """ Returns True if the user is an admin of one of the plugins corresponding to pluginNames plugins: a list of Plugin objects (e.g. EVO, RecordingRequest) or strings with the plugin name ('EVO', 'RecordingRequest') or the string 'any' (we will then check if the user is manager of any plugin), """ if not PluginsHolder().hasPluginType("Collaboration"): return False if user is None: if request is None: return False else: user = request._getUser() if user: collaborationPluginType = CollaborationTools.getCollaborationPluginType( ) plist = collaborationPluginType.getPluginList() \ if plugins == 'any' else plugins if plist: for plugin in plist: if not isinstance(plugin, Plugin): plugin = collaborationPluginType.getPlugin(plugin) if user in plugin.getOption('admins').getValue(): return True return False
def cleanAll(self): """ Wipes out everything """ CollaborationIndex.__init__(self) for pluginInfo in CollaborationTools.getCollaborationPluginType( ).getOption("pluginsPerIndex").getValue(): self._indexes[pluginInfo.getName()] = BookingsIndex( pluginInfo.getName())
def _checkParams(self): CollaborationBase._checkParams(self) if self._params.has_key('plugin'): self._plugin = self._params['plugin'] else: raise CollaborationException(_("Plugin name not set when trying to add or remove a manager on event: ") + str(self._conf.getId()) + _(" with the service ") + str(self.__class__) ) if CollaborationTools.getCollaborationPluginType().hasPlugin(self._plugin) and CollaborationTools.isAdminOnlyPlugin(self._plugin): raise CollaborationException(_("Tried to add or remove a manager for an admin-only plugin on event : ") + str(self._conf.getId()) + _(" with the service ") + str(self.__class__) )
def getVars(self): vars = wcomponents.WTemplated.getVars(self) #dictionary where the keys are names of false "indexes" for the user, and the values are IndexInformation objects indexes = CollaborationTools.getCollaborationPluginType().getOption("pluginsPerIndex").getValue() indexNames = set(i.getName() for i in indexes) indexList = ['all', None, 'Vidyo', 'EVO', 'CERNMCU', 'All Videoconference', None, 'WebcastRequest', 'RecordingRequest', 'All Requests'] vars["Indexes"] = [x for x in indexList if x is None or x in indexNames] vars["IndexInformation"] = fossilize(dict([(i.getName(), i) for i in indexes]), IIndexInformationFossil) vars["InitialIndex"] = self._queryParams["indexName"] vars["InitialViewBy"] = self._queryParams["viewBy"] vars["InitialOrderBy"] = self._queryParams["orderBy"] vars["InitialOnlyPending"] = self._queryParams["onlyPending"] vars["InitialConferenceId"] = self._queryParams["conferenceId"] vars["InitialCategoryId"] = self._queryParams["categoryId"] vars["InitialSinceDate"] = self._queryParams["sinceDate"] vars["InitialToDate"] = self._queryParams["toDate"] vars["InitialFromDays"] = self._queryParams["fromDays"] vars["InitialToDays"] = self._queryParams["toDays"] vars["InitialFromTitle"] = self._queryParams["fromTitle"] vars["InitialToTitle"] = self._queryParams["toTitle"] vars["InitialResultsPerPage"] = self._queryParams["resultsPerPage"] vars["InitialPage"] = self._queryParams["page"] vars["BaseURL"] = collaborationUrlHandlers.UHAdminCollaboration.getURL() vars["ConfCollaborationDisplay"] = collaborationUrlHandlers.UHCollaborationDisplay.getURL() if self._queryParams["queryOnLoad"]: ci = IndexesHolder().getById('collaboration') tz = self._rh._getUser().getTimezone() ##### minKey = None maxKey = None if self._queryParams['sinceDate']: minKey = setAdjustedDate(datetime.strptime(self._queryParams['sinceDate'].strip(), '%Y/%m/%d'), tz=tz) if self._queryParams['toDate']: maxKey = setAdjustedDate(datetime.strptime(self._queryParams['toDate'].strip(), '%Y/%m/%d'), tz=tz) if self._queryParams['fromTitle']: minKey = self._queryParams['fromTitle'].strip() if self._queryParams['toTitle']: maxKey = self._queryParams['toTitle'].strip() if self._queryParams['fromDays']: try: fromDays = int(self._queryParams['fromDays']) except ValueError, e: raise CollaborationException(_("Parameter 'fromDays' is not an integer"), inner = e) midnight = nowutc().replace(hour=0, minute=0, second=0) minKey = midnight - timedelta(days = fromDays) if self._queryParams['toDays']: try: toDays = int(self._queryParams['toDays']) except ValueError, e: raise CollaborationException(_("Parameter 'toDays' is not an integer"), inner = e) midnight_1 = nowutc().replace(hour=23, minute=59, second=59) maxKey = midnight_1 + timedelta(days = toDays)
def getVars(self): vars = wcomponents.WTemplated.getVars(self) #dictionary where the keys are names of false "indexes" for the user, and the values are IndexInformation objects indexes = CollaborationTools.getCollaborationPluginType().getOption("pluginsPerIndex").getValue() indexNames = set(i.getName() for i in indexes) indexList = ['all', None, 'Vidyo', 'EVO', 'CERNMCU', 'All Videoconference', None, 'WebcastRequest', 'RecordingRequest', 'All Requests'] vars["Indexes"] = [x for x in indexList if x is None or x in indexNames] vars["IndexInformation"] = fossilize(dict([(i.getName(), i) for i in indexes]), IIndexInformationFossil) vars["InitialIndex"] = self._queryParams["indexName"] vars["InitialViewBy"] = self._queryParams["viewBy"] vars["InitialOrderBy"] = self._queryParams["orderBy"] vars["InitialOnlyPending"] = self._queryParams["onlyPending"] vars["InitialConferenceId"] = self._queryParams["conferenceId"] vars["InitialCategoryId"] = self._queryParams["categoryId"] vars["InitialSinceDate"] = self._queryParams["sinceDate"] vars["InitialToDate"] = self._queryParams["toDate"] vars["InitialFromDays"] = self._queryParams["fromDays"] vars["InitialToDays"] = self._queryParams["toDays"] vars["InitialFromTitle"] = self._queryParams["fromTitle"] vars["InitialToTitle"] = self._queryParams["toTitle"] vars["InitialResultsPerPage"] = self._queryParams["resultsPerPage"] vars["InitialPage"] = self._queryParams["page"] vars["BaseURL"] = collaborationUrlHandlers.UHAdminCollaboration.getURL() vars["ConfCollaborationDisplay"] = collaborationUrlHandlers.UHCollaborationDisplay.getURL() if self._queryParams["queryOnLoad"]: ci = IndexesHolder().getById('collaboration') tz = self._rh._getUser().getTimezone() ##### minKey = None maxKey = None if self._queryParams['sinceDate']: minKey = setAdjustedDate(datetime.strptime(self._queryParams['sinceDate'].strip(), '%Y/%m/%d'), tz=tz) if self._queryParams['toDate']: maxKey = setAdjustedDate(datetime.strptime(self._queryParams['toDate'].strip(), '%Y/%m/%d'), tz=tz) if self._queryParams['fromTitle']: minKey = self._queryParams['fromTitle'].strip() if self._queryParams['toTitle']: maxKey = self._queryParams['toTitle'].strip() if self._queryParams['fromDays']: try: fromDays = int(self._queryParams['fromDays']) except ValueError, e: raise CollaborationException(_("Parameter 'fromDays' is not an integer"), inner = e) midnight = nowutc().replace(hour=0, minute=0, second=0) minKey = midnight - timedelta(days = fromDays) if self._queryParams['toDays']: try: toDays = int(self._queryParams['toDays']) except ValueError, e: raise CollaborationException(_("Parameter 'toDays' is not an integer"), inner = e) midnight_1 = nowutc().replace(hour=23, minute=59, second=59) maxKey = midnight_1 + timedelta(days = toDays)
def getVars( self ): vars = wcomponents.WTemplated.getVars( self ) #dictionary where the keys are names of false "indexes" for the user, and the values are IndexInformation objects vars["Indexes"] = CollaborationTools.getCollaborationPluginType().getOption("pluginsPerIndex").getValue() vars["InitialIndex"] = self._queryParams["indexName"] vars["InitialViewBy"] = self._queryParams["viewBy"] vars["InitialOrderBy"] = self._queryParams["orderBy"] vars["InitialOnlyPending"] = self._queryParams["onlyPending"] vars["InitialConferenceId"] = self._queryParams["conferenceId"] vars["InitialCategoryId"] = self._queryParams["categoryId"] vars["InitialSinceDate"] = self._queryParams["sinceDate"] vars["InitialToDate"] = self._queryParams["toDate"] vars["InitialFromDays"] = self._queryParams["fromDays"] vars["InitialToDays"] = self._queryParams["toDays"] vars["InitialFromTitle"] = self._queryParams["fromTitle"] vars["InitialToTitle"] = self._queryParams["toTitle"] vars["InitialResultsPerPage"] = self._queryParams["resultsPerPage"] vars["InitialPage"] = self._queryParams["page"] vars["BaseURL"] = urlHandlers.UHAdminCollaboration.getURL() if self._queryParams["queryOnLoad"]: ci = IndexesHolder().getById('collaboration') tz = self._rh._getUser().getTimezone() ##### minKey = None maxKey = None if self._queryParams['sinceDate']: minKey = setAdjustedDate(parseDateTime(self._queryParams['sinceDate'].strip()), tz = self._tz) if self._queryParams['toDate']: maxKey = setAdjustedDate(parseDateTime(self._queryParams['toDate'].strip()), tz = self._tz) if self._queryParams['fromTitle']: minKey = self._queryParams['fromTitle'].strip() if self._queryParams['toTitle']: maxKey = self._queryParams['toTitle'].strip() if self._queryParams['fromDays']: try: fromDays = int(self._queryParams['fromDays']) except ValueError, e: raise CollaborationException(_("Parameter 'fromDays' is not an integer"), inner = e) minKey = nowutc() - timedelta(days = fromDays) if self._queryParams['toDays']: try: toDays = int(self._queryParams['toDays']) except ValueError, e: raise CollaborationException(_("Parameter 'toDays' is not an integer"), inner = e) maxKey = nowutc() + timedelta(days = toDays)
def purgeNonExistingBookings(self): pluginList = set(CollaborationTools.getCollaborationPluginType().getPlugins()) for result in list(self._results): bookings = result[1] for b in list(bookings): doRemove = False try: if b.getType() not in pluginList: doRemove = True except AttributeError: doRemove = True if doRemove: bookings.remove(b) self._nBookings = self._nBookings - 1 if len(bookings) == 0: self._results.remove(result) self._nGroups = self._nGroups - 1
def _checkParams(self): CollaborationBase._checkParams(self) if self._params.has_key('plugin'): self._plugin = self._params['plugin'] else: raise CollaborationException( _("Plugin name not set when trying to add or remove a manager on event: " ) + str(self._conf.getId()) + _(" with the service ") + str(self.__class__)) if CollaborationTools.getCollaborationPluginType().hasPlugin( self._plugin) and CollaborationTools.isAdminOnlyPlugin( self._plugin): raise CollaborationException( _("Tried to add or remove a manager for an admin-only plugin on event : " ) + str(self._conf.getId()) + _(" with the service ") + str(self.__class__))
def purgeNonExistingBookings(self): pluginList = set( CollaborationTools.getCollaborationPluginType().getPlugins()) for result in list(self._results): bookings = result[1] for b in list(bookings): doRemove = False try: if b.getType() not in pluginList: doRemove = True except AttributeError: doRemove = True if doRemove: bookings.remove(b) self._nBookings = self._nBookings - 1 if len(bookings) == 0: self._results.remove(result) self._nGroups = self._nGroups - 1
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 cleanAll(self): """ Wipes out everything """ CollaborationIndex.__init__(self) for pluginInfo in CollaborationTools.getCollaborationPluginType().getOption("pluginsPerIndex").getValue(): self._indexes[pluginInfo.getName()] = BookingsIndex(pluginInfo.getName())