Example #1
0
    def eventDetailFooter(cls, obj, vars):
        """
        Add the footer extension for the statistics tracking.
        """
        stats = PluginsHolder().getPluginType('statistics')
        register = StatisticsRegister()

        if not stats.isActive() or not register.hasActivePlugins():
            return False

        key = 'extraFooterContent'
        extension = {}
        tracking = {}

        tracking['trackingActive'] = True
        tracking['trackingHooks'] = register.getAllPluginJSHooks(obj)

        # Build the extension object to be passed to the footer.
        extension['path'] = register.getJSInjectionPath()
        extension['args'] = tracking

        if key not in vars:
            vars[key] = [extension]
        else:
            vars[key].append(extension)
 def getOptionValueRooms(cls, pluginId, optionName):
     """ Returns the room list of an option with type 'rooms' of a plugin (plugins/Collaboration/XXXXX/options.py)
         pluginName: a string with the name of the plugin
         optionName: a string with the name of the option
     """
     ph = PluginsHolder()
     return ph.getPluginType("Collaboration").getPlugin(pluginId).getOption(optionName).getRooms()
Example #3
0
 def _checkParams(self):
     AdminService._checkParams(self)
     ph = PluginsHolder()
     self._targetOption = ph.getPluginType('EPayment').getOption(
         "customCurrency")
     self._currencyName = self._params.get('name', None)
     self._currencies = self._targetOption.getValue()
Example #4
0
    def eventDetailFooter(cls, obj, vars):
        """
        Add the footer extension for the statistics tracking.
        """
        stats = PluginsHolder().getPluginType('statistics')
        register = StatisticsRegister()

        if not stats.isActive() or not register.hasActivePlugins():
            return False

        key = 'extraFooterContent'
        extension = {}
        tracking = {}

        tracking['trackingActive'] = True
        tracking['trackingHooks'] = register.getAllPluginJSHooks(obj)

        # Build the extension object to be passed to the footer.
        extension['path'] = register.getJSInjectionPath()
        extension['args'] = tracking

        if key not in vars:
            vars[key] = [extension]
        else:
            vars[key].append(extension)
 def getOptionValue(cls, pluginId, optionName):
     """ Returns the value of an option of a plugin (plugins/Collaboration/XXXXX/options.py)
         pluginName: a string with the name of the plugin
         optionName: a string with the name of the option
     """
     ph = PluginsHolder()
     return ph.getPluginType("Collaboration").getPlugin(pluginId).getOption(optionName).getValue()
Example #6
0
    def getVars(self):
        ph = PluginsHolder()

        tplVars = WTemplated.getVars(self)
        tplVars["epayment_htdocs"] = UHEPaymentHtdocs.getURL()
        tplVars["currency_data"] = ph.getPluginType('EPayment').getOption("customCurrency").getValue()
        return tplVars
Example #7
0
 def getOptionValue(cls, pluginId, optionName):
     """ Returns the value of an option of a plugin (plugins/Collaboration/XXXXX/options.py)
         pluginName: a string with the name of the plugin
         optionName: a string with the name of the option
     """
     ph = PluginsHolder()
     return ph.getPluginType("Collaboration").getPlugin(pluginId).getOption(
         optionName).getValue()
Example #8
0
 def getOptionValueRooms(cls, pluginId, optionName):
     """ Returns the room list of an option with type 'rooms' of a plugin (plugins/Collaboration/XXXXX/options.py)
         pluginName: a string with the name of the plugin
         optionName: a string with the name of the option
     """
     ph = PluginsHolder()
     return ph.getPluginType("Collaboration").getPlugin(pluginId).getOption(
         optionName).getRooms()
Example #9
0
    def getVars(self):
        ph = PluginsHolder()

        tplVars = WTemplated.getVars(self)
        tplVars["epayment_htdocs"] = UHEPaymentHtdocs
        tplVars["currency_data"] = ph.getPluginType('EPayment').getOption(
            "customCurrency").getValue()
        return tplVars
Example #10
0
 def __init__(self, pluginType, plugin=None):
     self._pluginType = pluginType
     self._plugin = plugin
     try:
         from MaKaC.plugins import PluginsHolder
         if self._plugin:
             self._plugin = PluginsHolder().getPluginType(pluginType).getPlugin(plugin)
         else:
             self._pluginType = PluginsHolder().getPluginType(pluginType)
     except Exception, e:
         Logger.get('Plugins').error("Exception while trying to access either the plugin type %s or the plugin %s: %s" % (pluginType, plugin, str(e)))
         raise Exception("Exception while trying to access either the plugin type %s or the plugin %s: %s" % (pluginType, plugin, str(e)))
Example #11
0
    def getVars(self):
        vars = wcomponents.WTemplated.getVars(self)
        vars["HasCollaboration"] = PluginsHolder().hasPluginType(
            "Collaboration")
        vars["HasImporter"] = PluginsHolder().hasPluginType("importer")
        vars["HasChat"] = PluginsHolder().hasPluginType("InstantMessaging")
        vars["IsAdmin"] = RCAdmin.hasRights(self._rh)
        if PluginsHolder().hasPluginType("Collaboration"):
            from MaKaC.webinterface.rh.collaboration import RCCollaborationAdmin
            vars["IsCollaborationAdmin"] = RCCollaborationAdmin.hasRights(
                self._rh)
        else:
            vars["IsCollaborationAdmin"] = False

        return vars
Example #12
0
    def getList( self ):

        ph = PluginsHolder()
        if ph.hasPluginType("EPayment"):
            self._targetOption = ph.getPluginType("EPayment").getOption("customCurrency")
            currencies = self._targetOption.getValue()
            currenciesList = []
            for currency in currencies:
                currenciesList.append(currency["abbreviation"])
            return currenciesList

        else:
            raise ServiceError('ERR-PLUG3', 'pluginType: ' + str("EPayment") + ' does not exist, is not visible or not active')

        return [""]
Example #13
0
 def _checkParams(self, params):
     RHAdminBase._checkParams(self, params)
     self._pluginType = params.get("pluginType", None)
     #take out white spaces in case there are some
     if self._pluginType:
         self._pluginType = self._pluginType.replace(' ', '')
     self._pluginId = params.get("pluginId", None)
     #take out white spaces in case there are some
     if self._pluginId:
         self._pluginId = self._pluginId.replace(' ', '')
     self._ph = PluginsHolder()
     if self._pluginType and not self._ph.hasPluginType(self._pluginType, mustBeActive = False):
         raise PluginError("The plugin type " + self._pluginType + " does not exist or is not visible")
     elif self._pluginType and self._pluginId and not self._ph.getPluginType(self._pluginType).hasPlugin(self._pluginId):
         raise PluginError("The plugin " + self._pluginId + " does not exist")
Example #14
0
    def _checkProtection(self):
        if not PluginsHolder().hasPluginType("statistics"):
            raise PluginError(_("Statistics plugin is not active."))

        self._checkSessionUser()

        RHConferenceModifBase._checkProtection(self)
Example #15
0
    def hasRights(request, 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 not PluginsHolder().hasPluginType("Collaboration"):
            return False

        user = request.getAW().getUser()

        if user:
            csbm = request._conf.getCSBookingManager()
            if csbm.isVideoServicesManager(user):
                return True

            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
Example #16
0
    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
Example #17
0
    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
Example #18
0
 def _checkProtection(self):
     instantMessagingAdmins = []
     for imPlugin in PluginsHolder().getPluginType(
             'InstantMessaging').getPluginList():
         instantMessagingAdmins.extend(
             imPlugin.getOption("admins").getValue())
     if not self._getUser() in instantMessagingAdmins:
         RHConferenceModifBase._checkProtection(self)
Example #19
0
 def _checkParams(self):
     optionName = self._params.get('optionName', None)
     if optionName:
         options = optionName.split('.')
         ph = PluginsHolder()
         if len(options) == 3:
             pluginType, plugin, option = options
             if ph.hasPluginType(pluginType):
                 if ph.getPluginType(pluginType).hasPlugin(plugin):
                     self._targetOption = ph.getPluginType(
                         pluginType).getPlugin(plugin).getOption(option)
                 else:
                     raise ServiceError(
                         'ERR-PLUG4',
                         'plugin: ' + str(plugin) + ' does not exist')
             else:
                 raise ServiceError(
                     'ERR-PLUG3', 'pluginType: ' + str(pluginType) +
                     ' does not exist, is not visible or not active')
         elif len(options) == 2:
             pluginType, option = options
             if ph.hasPluginType(pluginType):
                 self._targetOption = ph.getPluginType(
                     pluginType).getOption(option)
             else:
                 raise ServiceError(
                     'ERR-PLUG3', 'pluginType: ' + str(pluginType) +
                     ' does not exist, is not visible or not active')
         else:
             raise ServiceError(
                 'ERR-PLUG1',
                 'optionName argument does not have the proper pluginType.plugin.option format'
             )
     else:
         raise ServiceError('ERR-PLUG0', 'optionName argument not present')
Example #20
0
    def getList(self):

        ph = PluginsHolder()
        if ph.hasPluginType("EPayment"):
            self._targetOption = ph.getPluginType("EPayment").getOption(
                "customCurrency")
            currencies = self._targetOption.getValue()
            currenciesList = []
            for currency in currencies:
                currenciesList.append(currency["abbreviation"])
            return currenciesList

        else:
            raise ServiceError(
                'ERR-PLUG3', 'pluginType: ' + str("EPayment") +
                ' does not exist, is not visible or not active')

        return [""]
Example #21
0
 def eventDetailBanner(self, obj, conf):
     if DBHelpers.roomsToShow(conf):
         vars = {}
         vars['chatrooms'] = DBHelpers.getShowableRooms(conf)
         vars['linksList'] = PluginsHolder().getPluginType('InstantMessaging').getOption('customLinks').getValue()
         vars['how2connect'] = PluginFieldsWrapper('InstantMessaging', 'XMPP').getOption('ckEditor')
         return WEventDetailBanner.forModule(InstantMessaging).getHTML(vars)
     else:
         return ""
 def getCollaborationPluginType(cls):
     #This commented code tried to gain some performance by caching the collaboration
     # PluginType object, but sometimes there would be problems by
     # different requests sharing memory and trying to access the database
     # after a connection was closed. This happened under Apache in Windows Vista with ZODB 3.8
     #        if not cls._cpt:
     #            cls._cpt = PluginsHolder().getPluginType("Collaboration")
     #        return cls._cpt
     return PluginsHolder().getPluginType("Collaboration")
Example #23
0
    def _checkProtection(self):
        if not PluginsHolder().hasPluginType("Collaboration"):
            raise PluginError("Collaboration plugin system is not active")

        if not RCCollaborationAdmin.hasRights(
                self, None
        ) and not RCCollaborationPluginAdmin.hasRights(
                self, plugins="any"
        ):  #RCCollaborationPluginAdmin.hasRights(self, None, self._tabPlugins):
            RHAdminBase._checkProtection(self)
Example #24
0
    def setUp(self):
        super(TestTasks, self).setUp()
        self._startDBReq()

        PluginsHolder().updateAllPluginInfo()
        PluginsHolder().getPluginType('calendaring').setActive(True)
        PluginsHolder().getPluginType('calendaring').getPlugin(
            'outlook').setActive(True)

        # Create two dummy users
        ah = AvatarHolder()
        self._avatar1 = Avatar()
        self._avatar1.setName("fake-1")
        self._avatar1.setSurName("fake1")
        self._avatar1.setOrganisation("fake1")
        self._avatar1.setEmail("*****@*****.**")
        ah.add(self._avatar1)
        self._avatar2 = Avatar()
        self._avatar2.setName("fake-2")
        self._avatar2.setSurName("fake2")
        self._avatar2.setOrganisation("fake2")
        self._avatar2.setEmail("*****@*****.**")
        ah.add(self._avatar2)

        # Create two dummy conferences
        category = conf.CategoryManager().getById('0')
        ch = ConferenceHolder()

        self._conf1 = category.newConference(self._avatar1)
        self._conf1.setTimezone('UTC')
        sd1 = datetime(2012, 12, 1, 10, 0, tzinfo=timezone('UTC'))
        ed1 = datetime(2012, 12, 1, 18, 0, tzinfo=timezone('UTC'))
        self._conf1.setDates(sd1, ed1)
        ch.add(self._conf1)

        self._conf2 = category.newConference(self._avatar2)
        self._conf2.setTimezone('UTC')
        sd2 = datetime(2012, 12, 10, 11, 0, tzinfo=timezone('UTC'))
        ed2 = datetime(2012, 12, 11, 13, 0, tzinfo=timezone('UTC'))
        self._conf2.setDates(sd2, ed2)
        ch.add(self._conf2)

        self._stopDBReq()
Example #25
0
    def _getAnswer(self):        
        #entries = json.loads(self._data)['data']
        try:
            from indico.util.ICTP_available_sponsors import ocirne_dictionary as available_sponsors
        except:
            available_sponsors = {}

        # init sponsor vocabulary
        plugin = PluginsHolder().getPluginType('ictp_addons').getPlugin("sponsor_management")
        #sponsors_array = plugin.getOptions()["sponsors"].getValue()
        sponsors_array = []

        if plugin.isActive():
            for k in available_sponsors.keys():
                d = available_sponsors[k]
                logo = ''
                if d.has_key('logo'):
                    logo = d['logo']
                elem = {
                    'name': k, 
                    'title': d['title'], 
                    'country': d['country'], 
                    'logo': logo,
                    'optionname': 'ictp_addons.sponsor_management.sponsors', 
                    'structure': d['url'],
                    }
                sponsors_array.append(elem)
            
            
        

        #return json.dumps({'success': True, 'table': sponsors_array})


        #print "addLink sponsors_array=",sponsors_array

        self._targetOption.setValue(sponsors_array)
        self._targetOption._notifyModification()
        #plugin.getOption("sponsors").setValue(sponsors_array)
        #print "addLink targetOption+",self._targetOption.getValue()
        
        return {'success': True, 'table': sponsors_array}
Example #26
0
    def hasRights(user):
        """ Returns True if the user is a Server Admin or a Collaboration admin
            user: an Avatar object
        """

        if user:
            # check if user is Server Admin, Collaboration Admin
            collaborationAdmins = PluginsHolder().getPluginType(
                'Collaboration').getOption('collaborationAdmins').getValue()
            return RCAdmin.hasRights(None, user) or user in collaborationAdmins
        return False
Example #27
0
    def hasRights(request=None, user=None):
        """ Returns True if the user is a Server Admin or a Collaboration admin
            request: an RH or Service object
            user: an Avatar object
            If user is None, the user will be retrieved from the request object.
        """
        if not PluginsHolder().hasPluginType("Collaboration"):
            return False

        if user is None:
            if request is None:
                return False
            else:
                user = request._getUser()

        # check if user is Server Admin, Collaboration Admin
        collaborationAdmins = PluginsHolder().getPluginType(
            'Collaboration').getOption('collaborationAdmins').getValue()

        return RCAdmin.hasRights(None, user) or user in collaborationAdmins
Example #28
0
    def _checkParams(self, params):
        RHConferenceModifBase._checkParams(self, params)

        self._activeTabName = params.get("tab", None)

        self._tabs = []
        #fill the tabs with the active plugins in the Instant Messaging module
        for plugin in PluginsHolder().getPluginType(
                'InstantMessaging').getPluginList():
            if plugin.isActive():
                self._tabs.append(plugin.getName())
Example #29
0
class RHAdminPluginsBase(RoomBookingDBMixin, RHAdminBase):
    """ Base RH class for all plugin management requests.
        It will store 2 string parameters: pluginType and pluginId.
        Example: pluginType = "COllaboration" & pluginId = "EVO"
    """

    def _checkParams(self, params):
        RHAdminBase._checkParams(self, params)
        self._pluginType = params.get("pluginType", None)
        #take out white spaces in case there are some
        if self._pluginType:
            self._pluginType = self._pluginType.replace(' ', '')
        self._pluginId = params.get("pluginId", None)
        #take out white spaces in case there are some
        if self._pluginId:
            self._pluginId = self._pluginId.replace(' ', '')
        self._ph = PluginsHolder()
        if self._pluginType and not self._ph.hasPluginType(self._pluginType, mustBeActive = False):
            raise PluginError("The plugin type " + self._pluginType + " does not exist or is not visible")
        elif self._pluginType and self._pluginId and not self._ph.getPluginType(self._pluginType).hasPlugin(self._pluginId):
            raise PluginError("The plugin " + self._pluginId + " does not exist")
Example #30
0
 def _checkSessionUser(self):
     user = self._getUser()
     if user == None:
         self._redirect(self._getLoginURL())
         self._doProcess = False
     else:
         try:
             if PluginsHolder().getPluginType("RoomBooking").isActive():
                 if not rb_check_user_access(user):
                     raise AccessError()
         except KeyError:
             pass
Example #31
0
 def _checkParams(self):
     optionName = self._params.get("optionName", None)
     if optionName:
         options = optionName.split(".")
         ph = PluginsHolder()
         if len(options) == 3:
             pluginType, plugin, option = options
             if ph.hasPluginType(pluginType):
                 if ph.getPluginType(pluginType).hasPlugin(plugin):
                     self._targetOption = ph.getPluginType(pluginType).getPlugin(plugin).getOption(option)
                 else:
                     raise ServiceError("ERR-PLUG4", "plugin: " + str(plugin) + " does not exist")
             else:
                 raise ServiceError(
                     "ERR-PLUG3", "pluginType: " + str(pluginType) + " does not exist, is not visible or not active"
                 )
         elif len(options) == 2:
             pluginType, option = options
             if ph.hasPluginType(pluginType):
                 self._targetOption = ph.getPluginType(pluginType).getOption(option)
             else:
                 raise ServiceError(
                     "ERR-PLUG3", "pluginType: " + str(pluginType) + " does not exist, is not visible or not active"
                 )
         else:
             raise ServiceError(
                 "ERR-PLUG1", "optionName argument does not have the proper pluginType.plugin.option format"
             )
     else:
         raise ServiceError("ERR-PLUG0", "optionName argument not present")
Example #32
0
    def _checkProtection(self):
        if not PluginsHolder().hasPluginType("Collaboration"):
            raise PluginError("Collaboration plugin system is not active")

        self._checkSessionUser()

        hasRights = (not self._cannotViewTab) and \
                    (RCCollaborationAdmin.hasRights(self, None) or
                     RCCollaborationPluginAdmin.hasRights(self, None, self._tabPlugins) or
                     RCVideoServicesManager.hasRights(self, self._tabPlugins) )

        if not hasRights:
            RHConferenceModifBase._checkProtection(self)
Example #33
0
 def _checkSessionUser(self):
     user = self._getUser()
     if user == None:
         self._redirect(self._getLoginURL())
         self._doProcess = False
     else:
         try:
             if PluginsHolder().getPluginType("RoomBooking").isActive():
                 if not AdminList.getInstance().isAdmin(
                         user) and PluginsHolder().getPluginType(
                             "RoomBooking").getOption(
                                 "AuthorisedUsersGroups").getValue() != []:
                     authenticatedUser = False
                     for entity in PluginsHolder().getPluginType(
                             "RoomBooking").getOption(
                                 "AuthorisedUsersGroups").getValue():
                         if isinstance(entity, Group) and entity.containsUser(user) or \
                            isinstance(entity, Avatar) and entity == user:
                             authenticatedUser = True
                             break
                     if not authenticatedUser:
                         raise AccessError()
         except KeyError:
             pass
Example #34
0
    def setup(cls):

        # lazy import because we don't want it to be imported by default
        # (as the plugin system currently loads all submodules)
        from indico.tests.config import TestConfig

        PluginsHolder().loadAllPlugins()

        testConfig = TestConfig.getInstance()
        vidyoOptions = CollaborationTools.getPlugin("Vidyo").getOptions()

        vidyoOptions["indicoUsername"].setValue(testConfig.getCollaborationOptions()["Vidyo"]["indicoUsername"])
        vidyoOptions["indicoPassword"].setValue(testConfig.getCollaborationOptions()["Vidyo"]["indicoPassword"])

        cls._setupDone = True
Example #35
0
 def _checkParams(self):
     optionName = self._params.get('optionName', None)
     if optionName:
         options = optionName.split('.')
         ph = PluginsHolder()
         if len(options) == 3:
             pluginType, plugin, option = options
             if ph.hasPluginType(pluginType):
                 if ph.getPluginType(pluginType).hasPlugin(plugin):
                     self._targetOption = ph.getPluginType(pluginType).getPlugin(plugin).getOption(option)
                 else:
                     raise ServiceError('ERR-PLUG4', 'plugin: ' + str(plugin) + ' does not exist')
             else:
                 raise ServiceError('ERR-PLUG3', 'pluginType: ' + str(pluginType) + ' does not exist, is not visible or not active')
         elif len(options) == 2:
             pluginType, option = options
             if ph.hasPluginType(pluginType):
                 self._targetOption = ph.getPluginType(pluginType).getOption(option)
             else:
                 raise ServiceError('ERR-PLUG3', 'pluginType: ' + str(pluginType) + ' does not exist, is not visible or not active')
         else:
             raise ServiceError('ERR-PLUG1', 'optionName argument does not have the proper pluginType.plugin.option format')
     else:
         raise ServiceError('ERR-PLUG0', 'optionName argument not present')
 def getCustomerUsername(self):
     ph = PluginsHolder()
     return ph.getPluginType("EPayment").getPlugin("eWay").getOption("customer_username").getValue()
 def getUrl(self):
     ph = PluginsHolder()
     return ph.getPluginType("EPayment").getPlugin("eWay").getOption("url").getValue()
Example #38
0
 def _checkParams(self):
     AdminService._checkParams(self)
     ph = PluginsHolder()
     self._targetOption = ph.getPluginType("EPayment").getOption("customCurrency")
     self._currencyName = self._params.get("name", None)
     self._currencies = self._targetOption.getValue()
Example #39
0
 def _checkProtection(self):
     if not PluginsHolder().hasPluginType("Collaboration"):
         raise PluginError("Collaboration plugin system is not active")
     if not RCVideoServicesManager.hasRights(self):
         RHConferenceModifBase._checkProtection(self)
Example #40
0
 def _sendEventRequest(self, key, eventType, avatar, conference):
     try:
         logger = self.getLogger()
         plugin = PluginsHolder().getPluginType('calendaring').getPlugin('outlook')
         if not isUserPluginEnabled(avatar.getId()):
             logger.info("Outlook plugin disabled for user: {}".format(avatar.getId()))
             return {'status_code': 200}
         if eventType in ['added', 'updated']:
             logger.debug("Performing '{}' for: {}".format(eventType, avatar.getId()))
             url = urlHandlers.UHConferenceDisplay.getURL(conference)
             location = strip_control_chars(conference.getRoom().getName()) if conference.getRoom() else ''
             description = strip_control_chars(conference.getDescription())
             self.payload = {'userEmail': avatar.getEmail(),
                             'uniqueID': plugin.getOption('prefix').getValue() + key,
                             'subject': strip_control_chars(conference.getTitle()),
                             'location': location,
                             'body': '<a href="{}">{}</a><br><br>{}'.format(url, url, description),
                             'status': plugin.getOption('status').getValue(),
                             'startDate': format_datetime(conference.getStartDate(),
                                                          format=plugin.getOption('datetimeFormat').getValue(),
                                                          timezone=pytz.utc),
                             'endDate': format_datetime(conference.getEndDate(),
                                                        format=plugin.getOption('datetimeFormat').getValue(),
                                                        timezone=pytz.utc),
                             'isThereReminder': plugin.getOption('reminder').getValue(),
                             'reminderTimeInMinutes': plugin.getOption('reminder_minutes').getValue()}
             operation = plugin.getOption('addToCalendarOperationName').getValue() if eventType == 'added' else plugin.getOption('updateCalendarOperationName').getValue()
         elif eventType == 'removed':
             logger.debug("Removing calendar entry for: {}".format(avatar.getId()))
             self.payload = {'userEmail': avatar.getEmail(),
                             'uniqueID': plugin.getOption('prefix').getValue() + key}
             operation = plugin.getOption('removeFromCalendarOperationName').getValue()
         else:
             return None
         headers = {'content-type': 'application/x-www-form-urlencoded'}
         return requests.post(urlpath.tslash(plugin.getOption('url').getValue()) + operation,
                              auth=(plugin.getOption('login').getValue(), plugin.getOption('password').getValue()),
                              data=self.payload, headers=headers, timeout=plugin.getOption('timeout').getValue())
     except requests.exceptions.Timeout:
         logger.exception('Timeout')
     except requests.exceptions.RequestException:
         logger.exception('RequestException: Connection problem')
     except Exception, e:
         logger.exception('Outlook EventException: {}'.format(e))
Example #41
0
def runTests(host='localhost', port=FAKE_SERVICE_PORT,
             scenarios=[(2, 10)]):

    execTimes = []

    agent = InvenioBatchUploaderAgent('test1', 'test1', 'test',
                                      0, 'http://%s:%s' \
                                      % (host, port))

    ph = PluginsHolder()
    ph.reloadAllPlugins()
    ph.getPluginType('livesync').toggleActive()
    do = DummyObservable()

    do._notify('updateDBStructures', 'indico.ext.livesync',
                              None, None, None)

    sm = SyncManager.getDBInstance()

    sm.registerNewAgent(agent)

    cm = CategoryManager()

    avatar = user.Avatar()
    avatar.setName( "fake" )
    avatar.setSurName( "fake" )
    avatar.setOrganisation( "fake" )
    avatar.setLang( "en_GB" )
    avatar.setEmail( "*****@*****.**" )

    #registering user
    ah = user.AvatarHolder()
    ah.add(avatar)

    #setting up the login info
    li = user.LoginInfo( "dummyuser", "dummyuser" )
    ih = AuthenticatorMgr()
    userid = ih.createIdentity( li, avatar, "Local" )
    ih.add( userid )

    #activate the account
    avatar.activateAccount()

    #since the DB is empty, we have to add dummy user as admin
    minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
    al = minfo.getAdminList()
    al.grant( avatar )

    dummy = avatar

    ContextManager.destroy()

    HelperMaKaCInfo.getMaKaCInfoInstance().setDefaultConference(DefaultConference())

    cm.getRoot()

    do._notify('requestStarted')

    home = cm.getById('0')

    # execute code
    for nconf in range(0, 1000):
        conf = home.newConference(dummy)
        conf.setTitle('Test Conference %s' % nconf)

    do._notify('requestFinished')

    time.sleep(1)

    # params won't be used
    task = LiveSyncUpdateTask(dateutil.rrule.MINUTELY)

    for scen in scenarios:

        print "Scenario %s workers, size = %s " % scen,

        # configure scenario
        InvenioBatchUploaderAgent.NUM_WORKERS = scen[0]
        InvenioBatchUploaderAgent.BATCH_SIZE = scen[1]

        ts = time.time()
        # just run it
        task.run()

        te = time.time()
        execTimes.append(te - ts)

        print "%s" % (te - ts)

        sm._track._pointers['test1'] = None

    for i in range(0, len(execTimes)):
        results[scenarios[i]] = execTimes[i]
Example #42
0
 def _checkProtection(self):
     if not PluginsHolder().hasPluginType("search"):
         raise PluginError(_("Search plugin is not active."))
Example #43
0
def getGlobalData():
    return PluginsHolder().getPluginType('Collaboration').getPlugin(
        'CERNMCU').getGlobalData()