def _checkParams(self, params): RHConferenceModifBase._checkParams(self, params) self._activeTabName = params.get("tab", None) # we build the list 'allowedTabs', a list of all tabs that the user can see allowedTabs = CollaborationTools.getTabs(self._conf, self._getUser()) if self._target.canModify(self.getAW()) or RCVideoServicesManager.hasRights(self): allowedTabs.append('Managers') tabOrder = CollaborationTools.getCollaborationOptionValue('tabOrder') self._tabs = [] for tabName in tabOrder: if tabName in allowedTabs: self._tabs.append(tabName) allowedTabs.remove(tabName) for tabName in allowedTabs: if tabName != 'Managers': self._tabs.append(tabName) if 'Managers' in allowedTabs: self._tabs.append('Managers')
def _checkParams(self, params): RHConferenceModifBase._checkParams(self, params) self._activeTabName = params.get("tab", None) # we build the list 'allowedTabs', a list of all tabs that the user can see allowedTabs = CollaborationTools.getTabs(self._conf, self._getUser()) if self._target.canModify( self.getAW()) or RCVideoServicesManager.hasRights(self): allowedTabs.append('Managers') tabOrder = CollaborationTools.getCollaborationOptionValue('tabOrder') self._tabs = [] for tabName in tabOrder: if tabName in allowedTabs: self._tabs.append(tabName) allowedTabs.remove(tabName) for tabName in allowedTabs: if tabName != 'Managers': self._tabs.append(tabName) if 'Managers' in allowedTabs: self._tabs.append('Managers')
def _checkParams(self, params): RHConferenceModifBase._checkParams(self, params) self._activeTabName = params.get("tab", None) self._canSeeAllPluginTabs = self._target.canModify(self.getAW()) or RCCollaborationAdmin.hasRights(self) or RCVideoServicesManager.hasRights(self) # we build the list 'allowedTabs', a list of all tabs that the user can see if self._canSeeAllPluginTabs: #if the logged in user is event manager, server admin or collaboration admin: we show all plugin tabs allowedTabs = CollaborationTools.getTabs(self._conf) else: #else we show only the tabs of plugins of which the user is admin allowedTabs = CollaborationTools.getTabs(self._conf, self._getUser()) if self._target.canModify(self.getAW()) or RCVideoServicesManager.hasRights(self): allowedTabs.append('Managers') # we order the list of allowedTabs into the self._tabs list tabOrder = CollaborationTools.getCollaborationOptionValue('tabOrder') self._tabs = [] for tabName in tabOrder: if tabName in allowedTabs: self._tabs.append(tabName) allowedTabs.remove(tabName) for tabName in allowedTabs: if tabName != 'Managers': self._tabs.append(tabName) if 'Managers' in allowedTabs: self._tabs.append('Managers')
def getVars(self): vars = WCSPageTemplateBase.getVars(self) vars["EventTitle"] = self._conf.getTitle() vars["EventDescription"] = unescape_html( strip_ml_tags(self._conf.getDescription())).strip() defaultStartDate = self._conf.getAdjustedStartDate() - timedelta( 0, 0, 0, 0, CollaborationTools.getCollaborationOptionValue("startMinutes")) nowStartDate = getAdjustedDate( nowutc() - timedelta(0, 0, 0, 0, self._EVOOptions["allowedPastMinutes"].getValue() / 2), self._conf) vars["DefaultStartDate"] = formatDateTime( max(defaultStartDate, nowStartDate)) defaultEndDate = self._conf.getAdjustedEndDate() nowEndDate = nowStartDate + timedelta( 0, 0, 0, 0, self._EVOOptions["allowedMinutes"].getValue()) vars["DefaultEndDate"] = formatDateTime(max(defaultEndDate, nowEndDate)) communities = self._EVOOptions["communityList"].getValue( ) #a dict communityId : communityName communityItems = communities.items( ) # a list of tuples (communityId, communityName) communityItems.sort(key=lambda t: t[ 1]) # we sort by the second member of the tuple (the name) vars["Communities"] = communityItems return vars
def getInstance(cls, ravemAPIUrl = None, username = None, password = None): if cls._instance is None or (ravemAPIUrl is not None or username is not None or password is not None): if ravemAPIUrl is None: ravemAPIUrl = CollaborationTools.getCollaborationOptionValue('ravemAPIURL') if username is None: username = CollaborationTools.getCollaborationOptionValue('ravemUsername') if password is None: password = CollaborationTools.getCollaborationOptionValue('ravemPassword') try: cls._instance = RavemClient(username, password, ravemAPIUrl) except Exception: Logger.get("Ravem").exception("Problem building RavemClient") raise return cls._instance
def getInstance(cls, ravemAPIUrl = None, username = None, password = None): if cls._instance is None or (ravemAPIUrl is not None or username is not None or password is not None): if ravemAPIUrl is None: ravemAPIUrl = CollaborationTools.getCollaborationOptionValue('ravemAPIURL') if username is None: username = CollaborationTools.getCollaborationOptionValue('ravemUsername') if password is None: password = CollaborationTools.getCollaborationOptionValue('ravemPassword') try: client = requests.session(auth=HTTPDigestAuth(username, password), verify=False) cls._instance = RavemClient(client, ravemAPIUrl) except Exception: Logger.get("Ravem").exception("Problem building RavemClient") raise return cls._instance
def getInstance(cls, ravemAPIUrl = None, username = None, password = None): if cls._instance is None or (ravemAPIUrl is not None or username is not None or password is not None): if ravemAPIUrl is None: ravemAPIUrl = CollaborationTools.getCollaborationOptionValue('ravemAPIURL') if username is None: username = CollaborationTools.getCollaborationOptionValue('ravemUsername') if password is None: password = CollaborationTools.getCollaborationOptionValue('ravemPassword') try: client = requests.session(auth=HTTPDigestAuth(username, password), verify=False) cls._instance = RavemClient(client, ravemAPIUrl) except Exception: Logger.get("Ravem").exception("Problem building RavemClient") raise return cls._instance
def getInstance(cls, ravem_api_url=None, username=None, password=None): if cls._instance is None or (ravem_api_url is not None or username is not None or password is not None): if ravem_api_url is None: ravem_api_url = CollaborationTools.getCollaborationOptionValue( 'ravemAPIURL') if username is None: username = CollaborationTools.getCollaborationOptionValue( 'ravemUsername') if password is None: password = CollaborationTools.getCollaborationOptionValue( 'ravemPassword') try: cls._instance = RavemClient(username, password, ravem_api_url) except Exception: Logger.get("Ravem").exception("Problem building RavemClient") raise return cls._instance
def getVars(self): vars = WCSPageTemplateBase.getVars( self ) vars["EventTitle"] = self._conf.getTitle() vars["EventDescription"] = unescape_html(strip_ml_tags( self._conf.getDescription())).strip() defaultStartDate = self._conf.getAdjustedStartDate() - timedelta(0,0,0,0,CollaborationTools.getCollaborationOptionValue("startMinutes")) nowStartDate = getAdjustedDate(nowutc() - timedelta(0,0,0,0, self._EVOOptions["allowedPastMinutes"].getValue() / 2), self._conf) vars["DefaultStartDate"] = formatDateTime(max(defaultStartDate, nowStartDate)) defaultEndDate = self._conf.getAdjustedEndDate() nowEndDate = nowStartDate + timedelta(0,0,0,0, self._EVOOptions["allowedMinutes"].getValue()) vars["DefaultEndDate"] = formatDateTime(max(defaultEndDate, nowEndDate)) communities = self._EVOOptions["communityList"].getValue() #a dict communityId : communityName communityItems = communities.items() # a list of tuples (communityId, communityName) communityItems.sort(key = lambda t: t[1]) # we sort by the second member of the tuple (the name) vars["Communities"] = communityItems return vars
def _checkParams(self, params): RHConferenceModifBase._checkParams(self, params) self._activeTabName = params.get("tab", None) self._canSeeAllPluginTabs = self._target.canModify( self.getAW()) or RCCollaborationAdmin.hasRights( self) or RCVideoServicesManager.hasRights(self) # we build the list 'allowedTabs', a list of all tabs that the user can see if self._canSeeAllPluginTabs: #if the logged in user is event manager, server admin or collaboration admin: we show all plugin tabs allowedTabs = CollaborationTools.getTabs(self._conf) else: #else we show only the tabs of plugins of which the user is admin allowedTabs = CollaborationTools.getTabs(self._conf, self._getUser()) if self._target.canModify( self.getAW()) or RCVideoServicesManager.hasRights(self): allowedTabs.append('Managers') # we order the list of allowedTabs into the self._tabs list tabOrder = CollaborationTools.getCollaborationOptionValue('tabOrder') self._tabs = [] for tabName in tabOrder: if tabName in allowedTabs: self._tabs.append(tabName) allowedTabs.remove(tabName) for tabName in allowedTabs: if tabName != 'Managers': self._tabs.append(tabName) if 'Managers' in allowedTabs: self._tabs.append('Managers')
def getBookings(self, indexName, viewBy, orderBy, minKey, maxKey, tz='UTC', onlyPending=False, conferenceId=None, categoryId=None, pickle=False, dateFormat=None, page=None, resultsPerPage=None, grouped=False): # TODO: Use iterators instead of lists if onlyPending: indexName += "_pending" reverse = orderBy == "descending" try: index = self.getIndex(indexName) totalInIndex = index.getCount() if categoryId and not CategoryManager().hasKey(categoryId) or conferenceId and \ not ConferenceHolder().hasKey(conferenceId): finalResult = QueryResult([], 0, 0, totalInIndex, 0) else: if viewBy == "conferenceTitle": items, nBookings = index.getBookingsByConfTitle( minKey, maxKey, conferenceId, categoryId) elif viewBy == "conferenceStartDate": items, nBookings = index.getBookingsByConfDate( minKey, maxKey, conferenceId, categoryId, tz, dateFormat, grouped=grouped) elif viewBy == "instanceDate": items, nBookings = self._getBookingInstancesByDate( indexName, dateFormat, minKey, maxKey) else: items, nBookings = index.getBookingsByDate( viewBy, minKey, maxKey, tz, conferenceId, categoryId, dateFormat) if reverse: items.reverse() nGroups = len(items) if page: page = int(page) if resultsPerPage: resultsPerPage = int(resultsPerPage) else: resultsPerPage = 10 nPages = nGroups / resultsPerPage if nGroups % resultsPerPage > 0: nPages = nPages + 1 if page > nPages: finalResult = QueryResult([], 0, 0, totalInIndex, nPages) else: finalResult = QueryResult( items[(page - 1) * resultsPerPage:page * resultsPerPage], nBookings, nGroups, totalInIndex, nPages) else: finalResult = QueryResult(items, nBookings, nGroups, totalInIndex, 0) except KeyError: Logger.get("VideoServ").warning( "Tried to retrieve index with name " + indexName + " but the index did not exist. Maybe no bookings have been added to it yet" ) finalResult = QueryResult([], 0, 0, 0, 0) if CollaborationTools.hasCollaborationOption( "verifyIndexingResults" ) and CollaborationTools.getCollaborationOptionValue( "verifyIndexingResults"): finalResult.purgeNonExistingBookings() if pickle: # ATTENTION: this call silently changes the fossil map CollaborationTools.updateIndexingFossilsDict() return fossilize(finalResult, IQueryResultFossil, tz=tz) else: return finalResult
def getBookings(self, indexName, viewBy, orderBy, minKey, maxKey, tz = 'UTC', onlyPending=False, conferenceId=None, categoryId=None, pickle=False, dateFormat=None, page=None, resultsPerPage=None, grouped=False): # TODO: Use iterators instead of lists if onlyPending: indexName += "_pending" reverse = orderBy == "descending" try: index = self.getIndex(indexName) totalInIndex = index.getCount() if categoryId and not CategoryManager().hasKey(categoryId) or conferenceId and \ not ConferenceHolder().hasKey(conferenceId): finalResult = QueryResult([], 0, 0, totalInIndex, 0) else: if viewBy == "conferenceTitle": items, nBookings = index.getBookingsByConfTitle(minKey, maxKey, conferenceId, categoryId) elif viewBy == "conferenceStartDate": items, nBookings = index.getBookingsByConfDate(minKey, maxKey, conferenceId, categoryId, tz, dateFormat, grouped=grouped) else: items, nBookings = index.getBookingsByDate(viewBy, minKey, maxKey, tz, conferenceId, categoryId, dateFormat) if reverse: items.reverse() nGroups = len(items) if page: page = int(page) if resultsPerPage: resultsPerPage = int(resultsPerPage) else: resultsPerPage = 10 nPages = nGroups / resultsPerPage if nGroups % resultsPerPage > 0: nPages = nPages + 1 if page > nPages: finalResult = QueryResult([], 0, 0, totalInIndex, nPages) else: finalResult = QueryResult(items[(page - 1) * resultsPerPage : page * resultsPerPage], nBookings, nGroups, totalInIndex, nPages) else: finalResult = QueryResult(items, nBookings, nGroups, totalInIndex, 0) except KeyError: Logger.get("VideoServ").warning("Tried to retrieve index with name " + indexName + " but the index did not exist. Maybe no bookings have been added to it yet") finalResult = QueryResult([], 0, 0, 0) if CollaborationTools.hasCollaborationOption("verifyIndexingResults") and CollaborationTools.getCollaborationOptionValue("verifyIndexingResults"): finalResult.purgeNonExistingBookings() if pickle: CollaborationTools.updateIndexingFossilsDict() return fossilize(finalResult, IQueryResultFossil, tz = tz) else: return finalResult