Exemple #1
0
 def remove( self ):
     """ Documentation in base class. """
     RoomBase.remove( self )
     roomsBTree = Room.getRoot()
     del roomsBTree[self.id]
     if Catalog.getIdx('user_room').has_obj(self.guid):
         Catalog.getIdx('user_room').unindex_obj(self.guid)
Exemple #2
0
 def remove( self ):
     """ Documentation in base class. """
     RoomBase.remove( self )
     roomsBTree = Room.getRoot()
     del roomsBTree[self.id]
     if Catalog.getIdx('user_room').has_obj(self.guid):
         Catalog.getIdx('user_room').unindex_obj(self.guid)
Exemple #3
0
 def deleted(cls, obj, params={}):
     if obj.__class__ == Conference:
         obj = Catalog.getIdx("cs_bookingmanager_conference").get(obj.getConference().getId())
         obj.notifyDeletion()
     elif obj.__class__ == Contribution and obj.getStartDate() is not None:
         csBookingManager = Catalog.getIdx("cs_bookingmanager_conference").get(obj.getConference().getId())
         for booking in csBookingManager.getBookingList():
             booking.unindex_talk(obj)
Exemple #4
0
    def cloneEvent(cls, confToClone, params):
        """ we'll clone the collaboration managers"""
        conf = params['conf']
        options = params['options']

        if options.get("access", True):
            for plugin, managers in Catalog.getIdx("cs_bookingmanager_conference").get(confToClone.getId()).getManagers().iteritems():
                for manager in managers:
                    Catalog.getIdx("cs_bookingmanager_conference").get(conf.getId()).addPluginManager(plugin, manager)
    def cloneEvent(cls, confToClone, params):
        """ we'll clone the collaboration managers"""
        conf = params['conf']
        options = params['options']

        if options.get("access", True):
            for plugin, managers in Catalog.getIdx("cs_bookingmanager_conference").get(confToClone.getId()).getManagers().iteritems():
                for manager in managers:
                    Catalog.getIdx("cs_bookingmanager_conference").get(conf.getId()).addPluginManager(plugin, manager)
Exemple #6
0
 def call(self):
     categ1 = CategoryManager().getById('1') #target category here
     for i in xrange(1, 0 + 1): #number of conferences to create here
         c = categ1.newConference(AvatarHolder().getById('1')) #creator of event
         c.setTitle("event " + str(i))
         c.setTimezone('UTC')
         c.setDates(nowutc() - timedelta(hours = i), nowutc() - timedelta(hours = i - 1))
         for j in xrange(1, 0+1): #number of bookings per event
             Catalog.getIdx("cs_bookingmanager_conference").get(c.getId()).createBooking("Vidyo", {"roomName":"room_"+str(i)+"_"+str(j),
                                                             "roomDescription": "test",
                                                             "owner":{"_type": "Avatar", "id":"1"}})
Exemple #7
0
 def _getAnswer(self):
     request_tokens = Catalog.getIdx('user_oauth_request_token').get(self._target.getId())
     access_tokens = Catalog.getIdx('user_oauth_access_token').get(self._target.getId())
     if request_tokens:
         for token in list(request_tokens):
             if token.getConsumer().getName() == self._third_party_app:
                 RequestTokenHolder().remove(token)
     if access_tokens:
         for token in list(access_tokens):
             if token.getConsumer().getName() == self._third_party_app:
                 AccessTokenHolder().remove(token)
     return True
Exemple #8
0
 def insert( self ):
     """ Documentation in base class. """
     RoomBase.insert( self )
     roomsBTree = Room.getRoot()
     # Ensure ID
     if self.id == None:
         # Maximum ID + 1
         if len( roomsBTree ) > 0:
             self.id = roomsBTree.maxKey() + 1
         else:
             self.id = 1 # Can not use maxKey for 1st record in a tree
     # Add self to the BTree
     roomsBTree[self.id] = self
     Catalog.getIdx('user_room').index_obj(self.guid)
Exemple #9
0
 def _getAnswer(self):
     request_tokens = Catalog.getIdx('user_oauth_request_token').get(
         self._target.getId())
     access_tokens = Catalog.getIdx('user_oauth_access_token').get(
         self._target.getId())
     if request_tokens:
         for token in list(request_tokens):
             if token.getConsumer().getName() == self._third_party_app:
                 RequestTokenHolder().remove(token)
     if access_tokens:
         for token in list(access_tokens):
             if token.getConsumer().getName() == self._third_party_app:
                 AccessTokenHolder().remove(token)
     return True
Exemple #10
0
    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)
Exemple #11
0
    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)
Exemple #12
0
 def insert( self ):
     """ Documentation in base class. """
     RoomBase.insert( self )
     roomsBTree = Room.getRoot()
     # Ensure ID
     if self.id == None:
         # Maximum ID + 1
         if len( roomsBTree ) > 0:
             self.id = roomsBTree.maxKey() + 1
         else:
             self.id = 1 # Can not use maxKey for 1st record in a tree
     # Add self to the BTree
     roomsBTree[self.id] = self
     Catalog.getIdx('user_room').index_obj(self.guid)
Exemple #13
0
 def _getAnswer( self ):
     index = Catalog.getIdx('categ_conf_sd').getCategory(self._categ.getId())
     skip = max(0, self._lastIdx - 100)
     pastEvents = {}
     num = 0
     events = list(islice(index.itervalues(), skip, self._lastIdx))
     preload_events(events, persons=True)
     for event in events:
         sd = event.getStartDate()
         key = (sd.year, sd.month)
         if key not in pastEvents:
             pastEvents[key] = {
                 'events': [],
                 'title': datetime(sd.year, sd.month, 1).strftime("%B %Y"),
                 'year': sd.year,
                 'month': sd.month
             }
         eventHTML = WConferenceListItem(event, self._aw).getHTML()
         pastEvents[key]['events'].append(eventHTML)
         num += 1
     for monthData in pastEvents.itervalues():
         monthData['events'].reverse()
     return {
         'num': num,
         'events': [v for k, v in sorted(pastEvents.iteritems(), reverse=True)]
     }
Exemple #14
0
    def iter_bookings(self, idList, categ_id=None):
        for vsid in idList:
            if vsid in ["webcast", "recording"]:
                idx = Catalog.getIdx("cs_booking_instance")[self.ID_TO_IDX[vsid]]
                for __, bkw in idx.iter_bookings(self._fromDT, self._toDT):
                    yield bkw
            else:
                idx = IndexesHolder().getById("collaboration")
                dateFormat = "%d/%m/%Y"

                tempBookings = idx.getBookings(
                    self.ID_TO_IDX[vsid],
                    "conferenceStartDate",
                    self._orderBy,
                    self._fromDT,
                    self._toDT,
                    "UTC",
                    False,
                    None,
                    categ_id,
                    False,
                    dateFormat,
                ).getResults()

                for evt, bks in tempBookings:
                    for bk in bks:
                        bk._conf = evt  # Ensure all CSBookings are aware of their Conference
                        yield bk
Exemple #15
0
 def getVars(self):
     vars = WTemplated.getVars( self )
     vars['user'] = self._avatar
     vars['currentUser'] = self._rh._getUser()
     vars["tokens"] = Catalog.getIdx('user_oauth_request_token').get(self._avatar.getId(), [])
     vars["formatTimestamp"] = lambda ts: format_datetime(utctimestamp2date(ts), format='d/M/yyyy H:mm')
     return vars
Exemple #16
0
    def _getAnswer(self):
        report = ", ".join(self.emailToList) + "."

        # {url} and {talkTitle} are mandatory to send the EA link
        if self.content.find("{url}") == -1:
            report = "url_error"
        elif self.content.find("{talkTitle}") == -1:
            report = "talkTitle_error"
        else:
            manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
            for uniqueId in self.uniqueIdList:
                sw = manager.getSpeakerWrapperByUniqueId(uniqueId)
                if sw.getStatus() not in [SpeakerStatusEnum.SIGNED, SpeakerStatusEnum.FROMFILE]:
                    sw.setStatus(SpeakerStatusEnum.PENDING)
                    subject = """[Indico] Electronic Agreement: '%s'""" % (self._conf.getTitle())
                    notification = ElectronicAgreementNotification(
                        [sw.getObject().getEmail()],
                        self.cc,
                        self.fromEmail,
                        self.fromName,
                        self.processContent(sw),
                        subject,
                    )

                    GenericMailer.sendAndLog(notification, self._conf, MODULE_NAME)
        return report
Exemple #17
0
    def hasRights(user, conf, plugins=[]):
        """ Returns True if the logged in user has rights to operate with bookings of at least one of a list of plugins, for an event.
            This is true if:
                -the user is a Video Services manager (can operate with all plugins)
                -the user is a plugin manager of one of the plugins
            Of course, it's also true if the user is event manager or server admin, but this class does not cover that case.

            request: an RH or Service object
            plugins: either a list of plugin names, or Plugin objects (we will then check if the user is manager of any of those plugins),
                     or the string 'any' (we will then check if the user is manager of any plugin),
                     or nothing (we will then check if the user is a Video Services manager).
        """

        if user:
            csbm = Catalog.getIdx("cs_bookingmanager_conference").get(
                conf.getId())
            if csbm.isVideoServicesManager(user):
                return True

            plugins = plugins
            if plugins == 'any':
                return csbm.isPluginManagerOfAnyPlugin(user)

            for plugin in plugins:
                if isinstance(plugin, Plugin):
                    plugin = plugin.getName()
                if csbm.isPluginManager(plugin, user):
                    return True
        return False
Exemple #18
0
    def getVars(self):
        vars = WCSPageTemplateBase.getVars( self )

        resultGetOrphans = getOrphans()
        if resultGetOrphans["success"] == True:
            orphans = resultGetOrphans["result"]
        else:
            raise RecordingManagerException(resultGetOrphans["result"])

        vars["Orphans"] = orphans
        talks = getTalks(self._conf, sort = True)
        vars["Talks"] = talks
        vars["Conference"] = self._conf
        previewURL = CollaborationTools.getOptionValue("RecordingManager", "micalaPreviewURL")
        if self._rh.use_https():
            previewURL = previewURL.replace("http","https")
        vars["PreviewURL"] = previewURL

        langPrimary = CollaborationTools.getOptionValue("RecordingManager", "languageCodePrimary")
        langSecondary = CollaborationTools.getOptionValue("RecordingManager", "languageCodeSecondary")
        langDict = CollaborationTools.getOptionValue("RecordingManager", "languageDictionary")
        (vars["FlagLanguageDataOK"], vars["LanguageErrorMessages"]) = \
            self._checkLanguageData(langPrimary, langSecondary, langDict)
        vars["LanguageCodePrimary"]   = langPrimary
        vars["LanguageCodeSecondary"] = langSecondary
        vars["LanguageDictionary"]    = langDict
        vars["LanguageCodes"]         = sorted(CollaborationTools.getOptionValue("RecordingManager", "languageDictionary").keys())
        vars["manager"] = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
        return vars
Exemple #19
0
    def eventTitleChanged(cls, obj, oldTitle, newTitle):

        obj = Catalog.getIdx("cs_bookingmanager_conference").get(obj.getConference().getId())
        try:
            obj.notifyTitleChange(oldTitle, newTitle)
        except Exception, e:
            Logger.get('PluginNotifier').error("Exception while trying to access to the title parameters when changing an event title" + str(e))
Exemple #20
0
 def export_eAgreements(self, aw):
     manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
     requestType = CollaborationTools.getRequestTypeUserCanManage(self._conf, aw.getUser())
     contributions = manager.getContributionSpeakerByType(requestType)
     for cont, speakers in contributions.items():
         for spk in speakers:
             sw = manager.getSpeakerWrapperByUniqueId('%s.%s' % (cont, spk.getId()))
             if not sw:
                 continue
             signed = None
             if sw.getStatus() in (SpeakerStatusEnum.FROMFILE, SpeakerStatusEnum.SIGNED):
                 signed = True
             elif sw.getStatus() == SpeakerStatusEnum.REFUSED:
                 signed = False
             yield {
                 'confId': sw.getConference().getId(),
                 'contrib': cont,
                 'type': sw.getRequestType(),
                 'status': sw.getStatus(),
                 'signed': signed,
                 'speaker': {
                     'id': spk.getId(),
                     'name': spk.getFullName(),
                     'email': spk.getEmail()
                 }
             }
Exemple #21
0
    def getVars(self):
        wvars = WConfDisplayBodyBase.getVars(self)

        csbm = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
        pluginNames = csbm.getEventDisplayPlugins()
        bookings = csbm.getBookingList(filterByType=pluginNames, notify=True, onlyPublic=True)
        bookings.sort(key=lambda b: b.getStartDate() or minDatetime())

        timeless_bookings = []
        ongoingBookings = []
        scheduledBookings = {} #date, list of bookings

        for b in bookings:
            if b.canBeDisplayed():
                if not b.hasStartDate():
                    timeless_bookings.append(b)
                else:
                    if b.isHappeningNow():
                        ongoingBookings.append(b)
                    elif b.getStartDate() and b.getAdjustedStartDate('UTC') > nowutc():
                        scheduledBookings.setdefault(b.getAdjustedStartDate(self._tz).date(), []).append(b)

        keys = scheduledBookings.keys()
        keys.sort()
        scheduledBookings = [(date, scheduledBookings[date]) for date in keys]

        wvars["body_title"] = self._getTitle()
        wvars["OngoingBookings"] = ongoingBookings
        wvars["ScheduledBookings"] = scheduledBookings
        wvars["timeless_bookings"] = timeless_bookings
        wvars["all_bookings"] = fossilize(bookings)
        wvars["Timezone"] = self._tz
        wvars["conf"] = self._conf

        return wvars
    def createAndAcceptBooking(self):
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())

        # Create a booking - Recording Request
        bookingParams =  {
                            'otherComments': '', 'endDate': '', 'talkSelection': ['0'], 'numAttendees': '', 'talks': '',
                            'lectureStyle': 'lecturePresentation', 'numRemoteViewers': '', 'startDate': '', 'postingUrgency': 'withinWeek'
                         }
        # Create a booking - Webcast Request
        bookingParamsWeb =  {
                           'talkSelection': ['0'], 'talks': 'choose'
                        }

        #Give rights to person3(recordingReq) and person4(webcastReq) (... _creator has both)
        manager.addPluginManager("RecordingRequest", self.person3)
        manager.addPluginManager("WebcastRequest", self.person4)

        if manager.canCreateBooking("RecordingRequest"):
            manager.createBooking("RecordingRequest", bookingParams)
        booking = manager.getSingleBooking("RecordingRequest")
        manager.acceptBooking(booking.getId())

        if manager.canCreateBooking("WebcastRequest"):
            manager.createBooking("WebcastRequest", bookingParamsWeb)
        booking = manager.getSingleBooking("WebcastRequest")
        manager.acceptBooking(booking.getId())
Exemple #23
0
    def getListSorted(self, dict):
        '''
        Function used to sort the dictionary containing the contributions and speakers of the single booking.
        It returns a sorted list of list with only the necessary information:
        [[spkId, spkName, spkStatus, contId], [spkId, spkName, spkStatus, contId], ...]
        '''
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
        lst = []

        sortMap = {'speaker': 1, 'status': 2, 'cont': 3, 'reqType': 4}
        reverse = False if self.order == 'down' else True

        for cont in dict:
            for id in dict[cont]:
                sw = manager.getSpeakerWrapperByUniqueId("%s.%s"%(cont, id.getId()))
                status = ""
                reqType = "NA"
                enabled = False
                if sw:
                    status = STATUS_STRING[sw.getStatus()]
                    reqType = sw.getRequestType()
                    enabled = sw.getStatus() not in [SpeakerStatusEnum.SIGNED, SpeakerStatusEnum.FROMFILE,
                                                     SpeakerStatusEnum.NOEMAIL]

                lst.append([id.getId(), id.getFullNameNoTitle(), status, cont, reqType, enabled])

        return sorted(lst, key=lambda x: x[sortMap[self.sortCriteria]], reverse=reverse)
    def eventTitleChanged(cls, obj, oldTitle, newTitle):

        obj = Catalog.getIdx("cs_bookingmanager_conference").get(obj.getConference().getId())
        try:
            obj.notifyTitleChange(oldTitle, newTitle)
        except Exception, e:
            Logger.get('PluginNotifier').error("Exception while trying to access to the title parameters when changing an event title" + str(e))
Exemple #25
0
 def getVars(self):
     wvars = WTemplated.getVars(self)
     wvars['user'] = self._avatar
     wvars['currentUser'] = self._rh._getUser()
     wvars["tokens"] = Catalog.getIdx('user_oauth_access_token').get(self._avatar.getId(), [])
     wvars["formatTimestamp"] = lambda ts: format_datetime(ts, format='d/M/yyyy H:mm')
     return wvars
Exemple #26
0
    def _getAnswer(self):
        spkWrapper = None
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(
            self._conf.getId())
        for sw in manager.getSpeakerWrapperList():
            if sw.getUniqueIdHash() == self.authKey:
                spkWrapper = sw

        if spkWrapper:
            spkWrapper.setStatus(SpeakerStatusEnum.SIGNED, request.remote_addr)
            spkWrapper.triggerNotification()
            if manager.notifyElectronicAgreementAnswer():
                subject = """[Indico] Electronic Agreement Accepted: '%s'""" % (
                    self._conf.getTitle())
                content = _(self.MESSAGE_ACCEPT).format(
                    speaker=spkWrapper.getObject().getDirectFullName(),
                    title=self._conf.getTitle(),
                    url=self._conf.getURL())
                emailToList = [self._conf.getCreator().getEmail()]
                for event_manager in self._conf.getManagerList():
                    emailToList.append(event_manager.getEmail())
                notification = ElectronicAgreementOrganiserNotification(
                    emailToList,
                    Config.getInstance().getNoReplyEmail(), content, subject)

                GenericMailer.sendAndLog(notification, self._conf, MODULE_NAME)
Exemple #27
0
 def export_eAgreements(self, aw):
     manager = Catalog.getIdx("cs_bookingmanager_conference").get(
         self._conf.getId())
     requestType = CollaborationTools.getRequestTypeUserCanManage(
         self._conf, aw.getUser())
     contributions = manager.getContributionSpeakerByType(requestType)
     for cont, speakers in contributions.items():
         for spk in speakers:
             sw = manager.getSpeakerWrapperByUniqueId('%s.%s' %
                                                      (cont, spk.getId()))
             if not sw:
                 continue
             signed = None
             if sw.getStatus() in (SpeakerStatusEnum.FROMFILE,
                                   SpeakerStatusEnum.SIGNED):
                 signed = True
             elif sw.getStatus() == SpeakerStatusEnum.REFUSED:
                 signed = False
             yield {
                 'confId': sw.getConference().getId(),
                 'contrib': cont,
                 'type': sw.getRequestType(),
                 'status': sw.getStatus(),
                 'signed': signed,
                 'speaker': {
                     'id': spk.getId(),
                     'name': spk.getFullName(),
                     'email': spk.getEmail()
                 }
             }
Exemple #28
0
    def _getAnswer(self):
        spkWrapper = None
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
        for sw in manager.getSpeakerWrapperList():
            if sw.getUniqueIdHash() == self.authKey:
                spkWrapper = sw

        if spkWrapper:
            spkWrapper.setStatus(SpeakerStatusEnum.REFUSED)
            spkWrapper.setRejectReason(self.reason)
            spkWrapper.triggerNotification()
            if manager.notifyElectronicAgreementAnswer():
                subject = """[Indico] Electronic Agreement Rejected: '%s'""" % (self._conf.getTitle())
                content = _(self.MESSAGE_REJECT).format(
                    speaker=spkWrapper.getObject().getDirectFullName(),
                    title=self._conf.getTitle(),
                    reason=self.reason,
                    url=self._conf.getURL())
                emailToList = [self._conf.getCreator().getEmail()]
                for event_manager in self._conf.getManagerList():
                    emailToList.append(event_manager.getEmail())
                notification = ElectronicAgreementOrganiserNotification(emailToList, Config.getInstance().getNoReplyEmail(), content, subject)

                GenericMailer.sendAndLog(notification, self._conf,
                                         MODULE_NAME)
    def getTabs(cls, conference, user):
        """ Returns a list of tab names corresponding to the active plugins for an event.
            If a user is specified, only tabs that a user can see are returned.
            A user can see a tab if:
            -The user is a Server Admin or a Video Services Admin
            -The user is a Plugin Admin of a plugin in that tab.
            -The user is an Event Manager or Video Services Manager and the plugin is not "admins only"
            -The user is a Plugin Manager of a plugin in that tab and the plugin is not "admins only"
        """
        tabNamesSet = set()

        csbm = Catalog.getIdx("cs_bookingmanager_conference").get(
            conference.getId())

        # we get the list of Plugin objects allowed for this kind of event
        if csbm is not None:
            allowedForThisEvent = csbm.getAllowedPlugins()

            for plugin in allowedForThisEvent:

                if cls.canUserManagePlugin(conference, plugin, user):
                    tabNamesSet.add(cls.getPluginTab(plugin))
                    EATab = cls.getEATab(plugin)
                    if EATab is not None:
                        tabNamesSet.add(EATab)

        tabNames = list(tabNamesSet)
        return tabNames
Exemple #30
0
    def iter_bookings(self, idList, categ_id=None):
        for vsid in idList:
            if vsid not in self.ID_TO_IDX:
                continue

            if vsid in ['webcast', 'recording']:
                idx = Catalog.getIdx('cs_booking_instance')[
                    self.ID_TO_IDX[vsid]]
                for __, bkw in idx.iter_bookings(self._fromDT, self._toDT):
                    yield bkw
            else:
                idx = IndexesHolder().getById('collaboration')
                dateFormat = '%d/%m/%Y'

                tempBookings = idx.getBookings(self.ID_TO_IDX[vsid],
                                               "conferenceStartDate",
                                               self._orderBy, self._fromDT,
                                               self._toDT, 'UTC', False, None,
                                               categ_id, False,
                                               dateFormat).getResults()

                for evt, bks in tempBookings:
                    for bk in bks:
                        bk._conf = evt  # Ensure all CSBookings are aware of their Conference
                        yield bk
Exemple #31
0
 def _process(self):
     try:
         user = self._request_token.getUser()
         access_tokens = Catalog.getIdx('user_oauth_access_token').get(user.getId())
         timestamp = nowutc()
         if access_tokens is not None:
             for access_token in list(access_tokens):
                 if access_token.getConsumer().getName() == self._request_token.getConsumer().getName():
                     access_token.setTimestamp(timestamp)
                     response = {'oauth_token': access_token.getId(),
                                 'oauth_token_secret': access_token.getToken().secret,
                                 'user_id': user.getId(),
                                 'oauth_token_ttl': Config.getInstance().getOAuthAccessTokenTTL(),
                                 'oauth_token_expiration_timestamp': access_token.getTimestamp() +
                                 timedelta(seconds=Config.getInstance().getOAuthAccessTokenTTL())}
                     return urlencode(response)
         access_token_key = OAuthUtils.gen_random_string()
         access_token_secret = OAuthUtils.gen_random_string()
         access_token = Token(access_token_key, oauth.Token(access_token_key, access_token_secret),
                              timestamp, self._request_token.getConsumer(), user)
         AccessTokenHolder().add(access_token)
         response = {'oauth_token': access_token_key,
                     'oauth_token_secret': access_token_secret,
                     'user_id': user.getId(),
                     'oauth_token_ttl': Config.getInstance().getOAuthAccessTokenTTL(),
                     'oauth_token_expiration_timestamp': access_token.getTimestamp() +
                     timedelta(seconds=Config.getInstance().getOAuthAccessTokenTTL())}
         return urlencode(response)
     except oauth.Error, err:
         raise OAuthError(err.message, 401)
Exemple #32
0
 def _checkThirdPartyAuthPermissible(self, consumer, user_id):
     request_token = Catalog.getIdx('user_oauth_request_token').get(user_id)
     if request_token is not None:
         for token in list(request_token):
             if token.getConsumer().getName() == consumer:
                 return token
     return None
Exemple #33
0
    def _getAnswer(self):
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
        resultList = []
        for cont in self.contList:
            resultList.extend(manager.getSpeakerEmailListByContribution(cont, self.userId))

        return resultList
Exemple #34
0
 def _getAnswer(self):
     index = Catalog.getIdx('categ_conf_sd').getCategory(
         self._categ.getId())
     skip = max(0, self._lastIdx - 100)
     pastEvents = {}
     num = 0
     for event in islice(index.itervalues(), skip, self._lastIdx):
         sd = event.getStartDate()
         key = (sd.year, sd.month)
         if key not in pastEvents:
             pastEvents[key] = {
                 'events': [],
                 'title': datetime(sd.year, sd.month, 1).strftime("%B %Y"),
                 'year': sd.year,
                 'month': sd.month
             }
         eventHTML = WConferenceListItem(event, self._aw).getHTML()
         pastEvents[key]['events'].append(eventHTML)
         num += 1
     for monthData in pastEvents.itervalues():
         monthData['events'].reverse()
     return {
         'num': num,
         'events':
         [v for k, v in sorted(pastEvents.iteritems(), reverse=True)]
     }
Exemple #35
0
 def _updateValidIdsAfterRemoveBooking(self, confId):
     self.cdbmgr.startRequest()
     if len(
             Catalog.getIdx("cs_bookingmanager_conference").get(
                 confId)._bookingsByType.get("DummyPlugin", [])) == 0:
         self.confsWithBookings.remove(confId)
     self.cdbmgr.endRequest()
Exemple #36
0
    def getVars(self):
        wvars = WConfDisplayBodyBase.getVars(self)

        csbm = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
        pluginNames = csbm.getEventDisplayPlugins()
        bookings = csbm.getBookingList(filterByType=pluginNames, notify=True, onlyPublic=True)
        bookings.sort(key=lambda b: b.getStartDate() or minDatetime())

        timeless_bookings = []
        ongoingBookings = []
        scheduledBookings = {} #date, list of bookings

        for b in bookings:
            if b.canBeDisplayed():
                if not b.hasStartDate():
                    timeless_bookings.append(b)
                else:
                    if b.isHappeningNow():
                        ongoingBookings.append(b)
                    elif b.getStartDate() and b.getAdjustedStartDate('UTC') > nowutc():
                        scheduledBookings.setdefault(b.getAdjustedStartDate(self._tz).date(), []).append(b)

        keys = scheduledBookings.keys()
        keys.sort()
        scheduledBookings = [(date, scheduledBookings[date]) for date in keys]

        wvars["body_title"] = self._getTitle()
        wvars["OngoingBookings"] = ongoingBookings
        wvars["ScheduledBookings"] = scheduledBookings
        wvars["timeless_bookings"] = timeless_bookings
        wvars["all_bookings"] = fossilize(bookings)
        wvars["Timezone"] = self._tz
        wvars["conf"] = self._conf

        return wvars
Exemple #37
0
    def getListSorted(self, dict):
        '''
        Function used to sort the dictionary containing the contributions and speakers of the single booking.
        It returns a sorted list of list with only the necessary information:
        [[spkId, spkName, spkStatus, contId], [spkId, spkName, spkStatus, contId], ...]
        '''
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
        lst = []

        sortMap = {'speaker': 1, 'status': 2, 'cont': 3, 'reqType': 4}
        reverse = False if self.order == 'down' else True

        for cont in dict:
            for id in dict[cont]:
                sw = manager.getSpeakerWrapperByUniqueId("%s.%s"%(cont, id.getId()))
                status = ""
                reqType = "NA"
                enabled = False
                if sw:
                    status = STATUS_STRING[sw.getStatus()]
                    reqType = sw.getRequestType()
                    enabled = sw.getStatus() not in [SpeakerStatusEnum.SIGNED, SpeakerStatusEnum.FROMFILE,
                                                     SpeakerStatusEnum.NOEMAIL]

                lst.append([id.getId(), id.getFullNameNoTitle(), status, cont, reqType, enabled])

        return sorted(lst, key=lambda list: lst[sortMap[self.sortCriteria]], reverse=reverse)
Exemple #38
0
    def _getAnswer(self):
        report = ', '.join(self.emailToList) + '.'

        #{url} and {talkTitle} are mandatory to send the EA link
        if self.content.find('{url}') == -1:
            report = "url_error"
        elif self.content.find('{talkTitle}') == -1:
            report = "talkTitle_error"
        else:
            manager = Catalog.getIdx("cs_bookingmanager_conference").get(
                self._conf.getId())
            for uniqueId in self.uniqueIdList:
                sw = manager.getSpeakerWrapperByUniqueId(uniqueId)
                if sw.getStatus() not in [
                        SpeakerStatusEnum.SIGNED, SpeakerStatusEnum.FROMFILE
                ]:
                    sw.setStatus(SpeakerStatusEnum.PENDING)
                    subject = """[Indico] Electronic Agreement: '%s'""" % (
                        self._conf.getTitle())
                    notification = ElectronicAgreementNotification(
                        [sw.getObject().getEmail()], self.cc, self.fromEmail,
                        self.fromName, self.processContent(sw), subject)

                    GenericMailer.sendAndLog(notification, self._conf,
                                             MODULE_NAME)
        return report
    def createAndAcceptBooking(self):
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())

        # Create a booking - Recording Request
        bookingParams =  {
                            'otherComments': '', 'endDate': '', 'talkSelection': ['0'], 'numAttendees': '', 'talks': '',
                            'lectureStyle': 'lecturePresentation', 'numRemoteViewers': '', 'startDate': '', 'postingUrgency': 'withinWeek'
                         }
        # Create a booking - Webcast Request
        bookingParamsWeb =  {
                           'talkSelection': ['0'], 'talks': 'choose'
                        }

        #Give rights to person3(recordingReq) and person4(webcastReq) (... _creator has both)
        manager.addPluginManager("RecordingRequest", self.person3)
        manager.addPluginManager("WebcastRequest", self.person4)

        if manager.canCreateBooking("RecordingRequest"):
            manager.createBooking("RecordingRequest", bookingParams)
        booking = manager.getSingleBooking("RecordingRequest")
        manager.acceptBooking(booking.getId())

        if manager.canCreateBooking("WebcastRequest"):
            manager.createBooking("WebcastRequest", bookingParamsWeb)
        booking = manager.getSingleBooking("WebcastRequest")
        manager.acceptBooking(booking.getId())
    def getPluginsByTab(cls, tabName, conference, user):
        """ Utility function that returns a list of plugin objects.
            These Plugin objects will be of the "Collaboration" type, and only those who have declared a subtab equal
            to the "tabName" argument will be returned.
            If tabName is None, [] is returned.
            The conference object is used to filter plugins that are not allowed in a conference,
            because of the conference type or the equipment of the conference room
            If a user is specified, only tabs with plugins that the user can see will be returned:
            -
        """
        if tabName:

            csbm = Catalog.getIdx("cs_bookingmanager_conference").get(
                conference.getId())

            if conference:
                allowedPlugins = csbm.getAllowedPlugins()
            else:
                allowedPlugins = None

            #we get the plugins of this tab
            return cls.getCollaborationPluginType().getPluginList(
                doSort=True,
                filterFunction=lambda plugin: cls.getPluginTab(plugin
                                                               ) == tabName and
                (allowedPlugins is None or plugin in allowedPlugins
                 ) and cls.canUserManagePlugin(conference, plugin, user))
        else:
            return []
    def getPluginsByTab(cls, tabName, conference, user):
        """ Utility function that returns a list of plugin objects.
            These Plugin objects will be of the "Collaboration" type, and only those who have declared a subtab equal
            to the "tabName" argument will be returned.
            If tabName is None, [] is returned.
            The conference object is used to filter plugins that are not allowed in a conference,
            because of the conference type or the equipment of the conference room
            If a user is specified, only tabs with plugins that the user can see will be returned:
            -
        """
        if tabName:

            csbm = Catalog.getIdx("cs_bookingmanager_conference").get(conference.getId())

            if conference:
                allowedPlugins = csbm.getAllowedPlugins()
            else:
                allowedPlugins = None

            #we get the plugins of this tab
            return cls.getCollaborationPluginType().getPluginList(
                doSort = True,
                filterFunction = lambda plugin: cls.getPluginTab(plugin) == tabName and
                                                (allowedPlugins is None or plugin in allowedPlugins) and
                                                cls.canUserManagePlugin(conference, plugin, user)
            )
        else:
            return []
    def getTabs(cls, conference, user):
        """ Returns a list of tab names corresponding to the active plugins for an event.
            If a user is specified, only tabs that a user can see are returned.
            A user can see a tab if:
            -The user is a Server Admin or a Video Services Admin
            -The user is a Plugin Admin of a plugin in that tab.
            -The user is an Event Manager or Video Services Manager and the plugin is not "admins only"
            -The user is a Plugin Manager of a plugin in that tab and the plugin is not "admins only"
        """
        tabNamesSet = set()

        csbm = Catalog.getIdx("cs_bookingmanager_conference").get(conference.getId())

        # we get the list of Plugin objects allowed for this kind of event
        if csbm is not None:
            allowedForThisEvent = csbm.getAllowedPlugins()

            for plugin in allowedForThisEvent:

                if cls.canUserManagePlugin(conference, plugin, user):
                    tabNamesSet.add(cls.getPluginTab(plugin))
                    EATab = cls.getEATab(plugin)
                    if EATab is not None:
                        tabNamesSet.add(EATab)

        tabNames = list(tabNamesSet)
        return tabNames
Exemple #43
0
    def hasRights(user, conf, plugins=[]):
        """ Returns True if the logged in user has rights to operate with bookings of at least one of a list of plugins, for an event.
            This is true if:
                -the user is a Video Services manager (can operate with all plugins)
                -the user is a plugin manager of one of the plugins
            Of course, it's also true if the user is event manager or server admin, but this class does not cover that case.

            request: an RH or Service object
            plugins: either a list of plugin names, or Plugin objects (we will then check if the user is manager of any of those plugins),
                     or the string 'any' (we will then check if the user is manager of any plugin),
                     or nothing (we will then check if the user is a Video Services manager).
        """

        if user:
            csbm = Catalog.getIdx("cs_bookingmanager_conference").get(conf.getId())
            if csbm.isVideoServicesManager(user):
                return True

            plugins = plugins
            if plugins == 'any':
                return csbm.isPluginManagerOfAnyPlugin(user)

            for plugin in plugins:
                if isinstance(plugin, Plugin):
                    plugin = plugin.getName()
                if csbm.isPluginManager(plugin, user):
                    return True
        return False
Exemple #44
0
 def eventDatesChanged(cls, obj, oldStartDate, oldEndDate,
                       newStartDate, newEndDate):
     obj = Catalog.getIdx("cs_bookingmanager_conference").get(obj.getConference().getId())
     try:
         obj.notifyEventDateChanges(oldStartDate, newStartDate,
                                    oldEndDate, newEndDate)
     except Exception, e:
         Logger.get('PluginNotifier').error("Exception while trying to access to the date parameters when changing an event date" + str(e))
Exemple #45
0
 def getVars(self):
     vars = wcomponents.WTemplated.getVars(self)
     vars["Conference"] = self._conf
     csbm = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
     vars["CSBM"] = csbm
     allManagers = fossilize(csbm.getAllManagers(), IAvatarFossil)
     vars["AllManagers"] = sorted(allManagers, cmp = UserComparator.cmpUsers)
     return vars
Exemple #46
0
 def call(self):
     cf = ConferenceHolder()
     for conf in cf.getValuesToList():
         csbm = Catalog.getIdx("cs_bookingmanager_conference").get(conf.getId())
         csbm._bookings = {}
         csbm._bookingsByType = {}
     collaborationIndex = IndexesHolder().getById("collaboration")
     collaborationIndex.cleanAll()
Exemple #47
0
 def addCheckBox2CloneConf(cls, obj, list):
     """ we show the clone checkbox if:
         * The Vidyo Plugin is active.
         * There are vidyo services in the event created by the user who wants to clone
     """
     #list of creators of the chat rooms
     if PluginsWrapper('Collaboration', 'Vidyo').isActive() and len(Catalog.getIdx("cs_bookingmanager_conference").get(obj._conf.getId()).getBookingList(filterByType="Vidyo")) !=0:
         list['cloneOptions'] += _("""<li><input type="checkbox" name="cloneVidyo" id="cloneVidyo" value="1" checked="checked"/>Vidyo</li>""")
 def confDisplaySMShow(cls, obj, params):
     obj._collaborationOpt = obj._sectionMenu.getLinkByName("collaboration")
     csbm = Catalog.getIdx("cs_bookingmanager_conference").get(obj._conf.getConference().getId())
     if csbm is not None and (not csbm.hasBookings() or not csbm.isCSAllowed()):
         if obj._collaborationOpt is None:
             displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(obj._conf.getConference(), True) # updating menu
             obj._collaborationOpt = obj._sectionMenu.getLinkByName("collaboration")
         obj._collaborationOpt.setVisible(False)
Exemple #49
0
 def _process(self):
     manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
     sw = manager.getSpeakerWrapperByUniqueId(self.spkUniqueId)
     if not sw:
         raise MaKaCError("The speaker wrapper id does not match any existing speaker.")
     self.file = sw.getLocalFile()
     return send_file(self.file.getFileName(), self.file.getFilePath(), self.file.getFileType(),
                      self.file.getCreationDate())
Exemple #50
0
 def confDisplaySMShow(cls, obj, params):
     obj._collaborationOpt = obj._sectionMenu.getLinkByName("collaboration")
     csbm = Catalog.getIdx("cs_bookingmanager_conference").get(obj._conf.getConference().getId())
     if csbm is not None and (not csbm.hasBookings() or not csbm.isCSAllowed()):
         if obj._collaborationOpt is None:
             displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(obj._conf.getConference(), True) # updating menu
             obj._collaborationOpt = obj._sectionMenu.getLinkByName("collaboration")
         obj._collaborationOpt.setVisible(False)
Exemple #51
0
 def call(self):
     cf = ConferenceHolder()
     for conf in cf.getValuesToList():
         csbm = Catalog.getIdx("cs_bookingmanager_conference").get(conf.getId())
         csbm._bookings = {}
         csbm._bookingsByType = {}
     collaborationIndex = IndexesHolder().getById("collaboration")
     collaborationIndex.cleanAll()
Exemple #52
0
 def getVars(self):
     vars = wcomponents.WTemplated.getVars(self)
     vars["Conference"] = self._conf
     csbm = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
     vars["CSBM"] = csbm
     allManagers = fossilize(csbm.getAllManagers(), IAvatarFossil)
     vars["AllManagers"] = sorted(allManagers, cmp = UserComparator.cmpUsers)
     return vars
 def eventDatesChanged(cls, obj, oldStartDate, oldEndDate,
                       newStartDate, newEndDate):
     obj = Catalog.getIdx("cs_bookingmanager_conference").get(obj.getConference().getId())
     try:
         obj.notifyEventDateChanges(oldStartDate, newStartDate,
                                    oldEndDate, newEndDate)
     except Exception, e:
         Logger.get('PluginNotifier').error("Exception while trying to access to the date parameters when changing an event date" + str(e))
Exemple #54
0
 def getVars(self):
     wvars = WTemplated.getVars(self)
     wvars['user'] = self._avatar
     wvars['currentUser'] = self._rh._getUser()
     wvars["tokens"] = Catalog.getIdx('user_oauth_access_token').get(
         self._avatar.getId(), [])
     wvars["formatTimestamp"] = lambda ts: format_datetime(
         ts, format='d/M/yyyy H:mm')
     return wvars
Exemple #55
0
    def _getAnswer(self):
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(
            self._conf.getId())
        resultList = []
        for cont in self.contList:
            resultList.extend(
                manager.getSpeakerEmailListByContribution(cont, self.userId))

        return resultList
Exemple #56
0
 def _process(self):
     manager = Catalog.getIdx("cs_bookingmanager_conference").get(
         self._conf.getId())
     sw = manager.getSpeakerWrapperByUniqueId(self.spkUniqueId)
     if not sw:
         raise MaKaCError(
             "The speaker wrapper id does not match any existing speaker.")
     self.file = sw.getLocalFile()
     return send_file(self.file.getFileName(), self.file.getFilePath(),
                      self.file.getFileType(), self.file.getCreationDate())
Exemple #57
0
 def infoChanged(cls, obj):
     #Update Speaker Wrapper only if obj is a Conference
     if isinstance(obj, Conference) or isinstance(obj, Contribution):
         bookingManager = Catalog.getIdx("cs_bookingmanager_conference").get(obj.getConference().getId())
         if not bookingManager:
             return
         try:
             bookingManager.notifyInfoChange()
         except Exception, e:
             Logger.get('PluginNotifier').error("Exception while trying to access the info changes " + str(e))
 def notifyDeletion(self, obj):
     # If the object it is a Conference we already made the deletion process
     # Take into account SessionSlot or Contributions
     if isinstance(
             obj, (SessionSlot,
                   Contribution)) and self.getLinkId() == obj.getUniqueId():
         csBookingManager = Catalog.getIdx(
             "cs_bookingmanager_conference").get(
                 obj.getConference().getId())
         csBookingManager.removeBooking(self.getId())