Esempio n. 1
0
 def _checkProtection(self):
     if not RCCollaborationAdmin.hasRights(
             self._getUser()) and not RCCollaborationPluginAdmin.hasRights(
                 self._getUser(), [self._bookingPlugin]):
         raise CollaborationException(
             _("You don't have the rights to perform this operation on this booking"
               ))
Esempio n. 2
0
    def getVars(self):
        from MaKaC.plugins.Collaboration.handlers import RCCollaborationAdmin
        from MaKaC.webinterface.rh.admins import RCAdmin

        vars = wcomponents.WTemplated.getVars(self)
        user = ContextManager.get("currentUser")
        vars["user"] = user
        vars["IsAdmin"] = RCAdmin.hasRights(self._rh)
        vars["IsCollaborationAdmin"] = RCCollaborationAdmin.hasRights(user)
        return vars
Esempio n. 3
0
    def getVars(self):
        from MaKaC.plugins.Collaboration.handlers import RCCollaborationAdmin
        from MaKaC.webinterface.rh.admins import RCAdmin

        vars = wcomponents.WTemplated.getVars(self)
        user = ContextManager.get("currentUser")
        vars["user"] = user
        vars["IsAdmin"] = RCAdmin.hasRights(self._rh)
        vars["IsCollaborationAdmin"] = RCCollaborationAdmin.hasRights(user)
        return vars
Esempio n. 4
0
    def _checkCanManagePlugin(self, plugin):
        isAdminOnlyPlugin = CollaborationTools.isAdminOnlyPlugin(plugin)

        hasAdminRights = RCCollaborationAdmin.hasRights(self._getUser()) or RCCollaborationPluginAdmin.hasRights(self._getUser(), [plugin])

        if not hasAdminRights and isAdminOnlyPlugin:
            raise CollaborationException(_("Cannot acces service of admin-only plugin if user is not admin, for event: ") + str(self._conf.getId()) + _(" with the service ") + str(self.__class__) )

        elif not hasAdminRights and not RCVideoServicesManager.hasRights(self._getUser(), self._conf, [plugin]):
            #we check if it's an event creator / manager (this will call ConferenceModifBase._checkProtection)
            ConferenceModifBase._checkProtection(self)
Esempio n. 5
0
    def _checkCanManagePlugin(self, plugin):
        isAdminOnlyPlugin = CollaborationTools.isAdminOnlyPlugin(plugin)

        hasAdminRights = RCCollaborationAdmin.hasRights(
            self._getUser()) or RCCollaborationPluginAdmin.hasRights(
                self._getUser(), [plugin])

        if not hasAdminRights and isAdminOnlyPlugin:
            raise CollaborationException(
                _("Cannot acces service of admin-only plugin if user is not admin, for event: "
                  ) + str(self._conf.getId()) + _(" with the service ") +
                str(self.__class__))

        elif not hasAdminRights and not RCVideoServicesManager.hasRights(
                self._getUser(), self._conf, [plugin]):
            #we check if it's an event creator / manager (this will call ConferenceModifBase._checkProtection)
            ConferenceModifBase._checkProtection(self)
    def canUserManagePlugin(cls, conference, plugin, user):
        """ Utility function that returns if a user can interact with a plugin inside an event,
            depending on the plugin, the user, and the event where the user tries to see a plugin page
            or change a plugin object
        """

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

        from MaKaC.plugins.Collaboration.handlers import RCCollaborationAdmin
        isAdminUser = RCCollaborationAdmin.hasRights(user)

        isAdminOnlyPlugin = cls.isAdminOnlyPlugin(plugin)

        canSee = (isAdminUser or user in plugin.getOption('admins').getValue()
                  or not isAdminOnlyPlugin and
                  (conference.canUserModify(user)
                   or csbm.isVideoServicesManager(user)
                   or csbm.isPluginManager(plugin.getName(), user)))

        return canSee
Esempio n. 7
0
    def canUserManagePlugin(cls, conference, plugin, user):
        """ Utility function that returns if a user can interact with a plugin inside an event,
            depending on the plugin, the user, and the event where the user tries to see a plugin page
            or change a plugin object
        """

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

        from MaKaC.plugins.Collaboration.handlers import RCCollaborationAdmin
        isAdminUser = RCCollaborationAdmin.hasRights(user)

        isAdminOnlyPlugin = cls.isAdminOnlyPlugin(plugin)

        canSee = (
                isAdminUser or
                user in plugin.getOption('admins').getValue() or
                not isAdminOnlyPlugin and (conference.canUserModify(user) or
                                           csbm.isVideoServicesManager(user) or
                                           csbm.isPluginManager(plugin.getName(), user) ) )

        return canSee
Esempio n. 8
0
    def getVars(self):
        vars = WCSPageTemplateBase.getVars( self )

        vars["IsSingleBooking"] = not CollaborationTools.getCSBookingClass(self._pluginId)._allowMultiple
        vars["Conference"] = self._conf

        isLecture = self._conf.getType() == 'simple_event'
        vars["IsLecture"] = isLecture

        underTheLimit = self._conf.getNumberOfContributions() <= self._RecordingRequestOptions["contributionLoadLimit"].getValue()
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
        user = self._rh._getUser()
        isManager = user.isAdmin() or RCCollaborationAdmin.hasRights(user) or \
            RCCollaborationPluginAdmin.hasRights(user, plugins=['RecordingRequest'])
        booking = manager.getSingleBooking('RecordingRequest')
        initialChoose = booking is not None and booking._bookingParams['talks'] == 'choose'
        initialDisplay = (self._conf.getNumberOfContributions() > 0 and underTheLimit) or (booking is not None and initialChoose)


        vars["InitialChoose"] = initialChoose
        vars["DisplayTalks"] = initialDisplay
        vars["isManager"] = isManager

        talks, rRoomFullNames, rRoomNames, recordingAbleTalks, recordingUnableTalks = getCommonTalkInformation(self._conf)
        nRecordingCapable = len(recordingAbleTalks)

        vars["HasRecordingCapableTalks"] = nRecordingCapable > 0
        vars["NTalks"] = len(talks)

        # list of "locationName:roomName" strings
        vars["RecordingCapableRooms"] = rRoomFullNames
        vars["NRecordingCapableContributions"] = nRecordingCapable

        # we check if the event itself is recoring capable (depends on event's room)
        confLocation = self._conf.getLocation()
        confRoom = self._conf.getRoom()
        if confLocation and confRoom and (confLocation.getName() + ":" + confRoom.getName() in rRoomNames):
            topLevelRecordingCapable = True
        else:
            topLevelRecordingCapable = False

        # Finally, this event is recoring capable if the event itself
        # or one of its talks are capable or user is admin, collaboration
        # manager or recording plugin manager
        vars["RecordingCapable"] = topLevelRecordingCapable or nRecordingCapable > 0 or isManager

        recordingAbleTalks.sort(key = Contribution.contributionStartDateForSort)
        talks.sort(key = Contribution.contributionStartDateForSort)

        fossil_args = dict(tz=self._conf.getTimezone(),
                           units='(hours)_minutes',
                           truncate=True)

        vars["Contributions"] = fossilize(talks, IContributionRRFossil, **fossil_args)
        vars["ContributionsAble"] = fossilize(recordingAbleTalks, IContributionRRFossil, **fossil_args)
        vars["ContributionsUnable"] = fossilize(recordingUnableTalks, IContributionRRFossil, **fossil_args)

        vars["PostingUrgency"] = postingUrgency
        vars["linkToEA"] = collaborationUrlHandlers.UHCollaborationElectronicAgreement.getURL(self._conf)
        vars["agreementName"] = CollaborationTools.getOptionValue("RecordingRequest", "AgreementName")
        return vars
Esempio n. 9
0
    def getVars(self):
        vars = wcomponents.WTemplated.getVars(self)

        plugins = self._tabPlugins
        singleBookingPlugins, multipleBookingPlugins = CollaborationTools.splitPluginsByAllowMultiple(plugins)
        csBookingManager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())

        bookingsS = {}

        for p in singleBookingPlugins:
            bookingList = csBookingManager.getBookingList(filterByType = p.getId())
            if len(bookingList) > 0:
                bookingsS[p.getId()] = fossilize(bookingList[0]) #will use ICSBookingConfModifBaseFossil or inheriting fossil

        bookingsM = fossilize(csBookingManager.getBookingList(
            sorted = True,
            notify = True,
            filterByType = [p.getName() for p in multipleBookingPlugins])) #will use ICSBookingConfModifBaseFossil or inheriting fossil

        vars["Conference"] = self._conf
        vars["AllPlugins"] = plugins
        vars["SingleBookingPlugins"] = singleBookingPlugins
        vars["BookingsS"] = bookingsS
        vars["MultipleBookingPlugins"] = multipleBookingPlugins
        vars["BookingsM"] = bookingsM
        vars["Tab"] = self._activeTab
        vars["EventDate"] = formatDateTime(getAdjustedDate(nowutc(), self._conf))

        from MaKaC.plugins.Collaboration.handlers import RCCollaborationAdmin, RCCollaborationPluginAdmin, RCVideoServicesUser

        vars["UserIsAdmin"] = RCCollaborationAdmin.hasRights(self._user) or RCCollaborationPluginAdmin.hasRights(self._user, plugins=self._tabPlugins)

        hasCreatePermissions = {}
        videoServSupport = {}
        isAllowedToSearch = {}
        for plugin in plugins:
            pname = plugin.getName()
            hasCreatePermissions[pname] = RCVideoServicesUser.hasRights(user=self._user, pluginName=pname)
            videoServSupport[pname] = plugin.getOption("contactSupport").getValue() \
                if plugin.hasOption("contactSupport") else ""
            isAllowedToSearch[pname] = plugin.getOption("searchAllow").getValue() if plugin.hasOption("searchAllow")  \
                else False
        vars["HasCreatePermissions"] = hasCreatePermissions
        vars["VideoServiceSupport"] = videoServSupport
        vars["isAllowedToSearch"] = isAllowedToSearch

        singleBookingForms = {}
        multipleBookingForms = {}
        jsCodes = {}
        canBeNotified = {}

        for plugin in singleBookingPlugins:
            pluginId = plugin.getId()
            templateClass = CollaborationTools.getTemplateClass(pluginId, "WNewBookingForm")
            singleBookingForms[pluginId] = templateClass(self._conf, plugin.getId(), self._user).getHTML()

        for plugin in multipleBookingPlugins:
            pluginId = plugin.getId()
            templateClass = CollaborationTools.getTemplateClass(pluginId, "WNewBookingForm")
            newBookingFormHTML = templateClass(self._conf, plugin.getId(), self._user).getHTML()

            advancedTabClass = CollaborationTools.getTemplateClass(pluginId, "WAdvancedTab")
            if advancedTabClass:
                advancedTabClassHTML = advancedTabClass(self._conf, plugin.getId(), self._user).getHTML()
            else:
                advancedTabClassHTML = WConfModifCollaborationDefaultAdvancedTab(self._conf, plugin, self._user).getHTML()
            multipleBookingForms[pluginId] = (newBookingFormHTML, advancedTabClassHTML)

        for plugin in plugins:
            pluginId = plugin.getId()

            templateClass = CollaborationTools.getTemplateClass(pluginId, "WMain")
            jsCodes[pluginId] = templateClass(self._conf, plugin.getId(), self._user).getHTML()

            bookingClass = CollaborationTools.getCSBookingClass(pluginId)
            canBeNotified[pluginId] = bookingClass._canBeNotifiedOfEventDateChanges

        vars["SingleBookingForms"] = singleBookingForms
        vars["MultipleBookingForms"] = multipleBookingForms
        vars["JSCodes"] = jsCodes
        vars["CanBeNotified"] = canBeNotified

        return vars
Esempio n. 10
0
 def _hasAccess(self, aw):
     return RCCollaborationAdmin.hasRights(user=aw.getUser())
Esempio n. 11
0
    def getVars(self):
        vars = WCSPageTemplateBase.getVars(self)

        vars["IsSingleBooking"] = not CollaborationTools.getCSBookingClass(
            self._pluginId)._allowMultiple
        vars["Conference"] = self._conf

        isLecture = self._conf.getType() == 'simple_event'
        vars["IsLecture"] = isLecture

        underTheLimit = self._conf.getNumberOfContributions(
        ) <= self._RecordingRequestOptions["contributionLoadLimit"].getValue()
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(
            self._conf.getId())
        user = self._rh._getUser()
        isManager = user.isAdmin() or RCCollaborationAdmin.hasRights(user) or \
            RCCollaborationPluginAdmin.hasRights(user, plugins=['RecordingRequest'])
        booking = manager.getSingleBooking('RecordingRequest')
        initialChoose = booking is not None and booking._bookingParams[
            'talks'] == 'choose'
        initialDisplay = (self._conf.getNumberOfContributions() > 0
                          and underTheLimit) or (booking is not None
                                                 and initialChoose)

        vars["InitialChoose"] = initialChoose
        vars["DisplayTalks"] = initialDisplay
        vars["isManager"] = isManager

        talks, rRoomFullNames, rRoomNames, recordingAbleTalks, recordingUnableTalks = getCommonTalkInformation(
            self._conf)
        nRecordingCapable = len(recordingAbleTalks)

        vars["HasRecordingCapableTalks"] = nRecordingCapable > 0
        vars["NTalks"] = len(talks)

        # list of "locationName:roomName" strings
        vars["RecordingCapableRooms"] = rRoomFullNames
        vars["NRecordingCapableContributions"] = nRecordingCapable

        # we check if the event itself is recoring capable (depends on event's room)
        confLocation = self._conf.getLocation()
        confRoom = self._conf.getRoom()
        if confLocation and confRoom and (confLocation.getName() + ":" +
                                          confRoom.getName() in rRoomNames):
            topLevelRecordingCapable = True
        else:
            topLevelRecordingCapable = False

        # Finally, this event is recoring capable if the event itself
        # or one of its talks are capable or user is admin, collaboration
        # manager or recording plugin manager
        vars[
            "RecordingCapable"] = topLevelRecordingCapable or nRecordingCapable > 0 or isManager

        recordingAbleTalks.sort(key=Contribution.contributionStartDateForSort)
        talks.sort(key=Contribution.contributionStartDateForSort)

        fossil_args = dict(tz=self._conf.getTimezone(),
                           units='(hours)_minutes',
                           truncate=True)

        vars["Contributions"] = fossilize(talks, IContributionRRFossil,
                                          **fossil_args)
        vars["ContributionsAble"] = fossilize(recordingAbleTalks,
                                              IContributionRRFossil,
                                              **fossil_args)
        vars["ContributionsUnable"] = fossilize(recordingUnableTalks,
                                                IContributionRRFossil,
                                                **fossil_args)

        vars["PostingUrgency"] = postingUrgency
        vars[
            "linkToEA"] = collaborationUrlHandlers.UHCollaborationElectronicAgreement.getURL(
                self._conf)
        vars["agreementName"] = CollaborationTools.getOptionValue(
            "RecordingRequest", "AgreementName")
        return vars
Esempio n. 12
0
 def isPluginTypeAdmin(self, obj, params={}):
     """ Returns True if the user is a Server Admin or a Collaboration admin
         user: an Avatar object
     """
     return RCCollaborationAdmin.hasRights(params.get("user", None))
Esempio n. 13
0
 def addParamsToHeaderItem(self, obj, params, itemList):
     user = params.get("user", None)
     if user:
         if (user.isAdmin() or RCCollaborationAdmin.hasRights(user) or RCCollaborationPluginAdmin.hasRights(user, plugins="any")) and CollaborationTools.anyPluginsAreActive():
             itemList.append({'id': 'vsOverview', 'url': UHAdminCollaboration.getURL(), 'text': _("Video Services Overview")})
Esempio n. 14
0
 def isPluginTypeAdmin(self, obj, params={}):
     """ Returns True if the user is a Server Admin or a Collaboration admin
         user: an Avatar object
     """
     return RCCollaborationAdmin.hasRights(params.get("user", None))
Esempio n. 15
0
 def isAllowedToAccess(self, obj, params):
     user = params["user"]
     return Catalog.getIdx("cs_bookingmanager_conference").get(params["conf"].getId()).isPluginManagerOfAnyPlugin(user) or \
         RCCollaborationAdmin.hasRights(user=user) or RCCollaborationPluginAdmin.hasRights(user=user, plugins ='any')
Esempio n. 16
0
 def _checkProtection(self):
     if not RCCollaborationAdmin.hasRights(self._getUser()) and not RCCollaborationPluginAdmin.hasRights(self._getUser(), [self._bookingPlugin]):
         raise CollaborationException(_("You don't have the rights to perform this operation on this booking"))
Esempio n. 17
0
 def addParamsToHeaderItem(self, obj, params, itemList):
     user = params.get("user", None)
     if user:
         if (user.isAdmin() or RCCollaborationAdmin.hasRights(user) or RCCollaborationPluginAdmin.hasRights(user, plugins="any")) and CollaborationTools.anyPluginsAreActive():
             itemList.append({'id': 'vsOverview', 'url': UHAdminCollaboration.getURL(), 'text': _("Video Services Overview")})
Esempio n. 18
0
 def _checkProtection(self):
     if not RCCollaborationAdmin.hasRights(self._getUser()):
         AdminService._checkProtection(self)
Esempio n. 19
0
    def getVars(self):
        vars = wcomponents.WTemplated.getVars(self)

        plugins = self._tabPlugins
        singleBookingPlugins, multipleBookingPlugins = CollaborationTools.splitPluginsByAllowMultiple(plugins)
        csBookingManager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())

        bookingsS = {}

        for p in singleBookingPlugins:
            bookingList = csBookingManager.getBookingList(filterByType = p.getId())
            if len(bookingList) > 0:
                bookingsS[p.getId()] = fossilize(bookingList[0]) #will use ICSBookingConfModifBaseFossil or inheriting fossil

        bookingsM = fossilize(csBookingManager.getBookingList(
            sorted = True,
            notify = True,
            filterByType = [p.getName() for p in multipleBookingPlugins])) #will use ICSBookingConfModifBaseFossil or inheriting fossil

        vars["Conference"] = self._conf
        vars["AllPlugins"] = plugins
        vars["SingleBookingPlugins"] = singleBookingPlugins
        vars["BookingsS"] = bookingsS
        vars["MultipleBookingPlugins"] = multipleBookingPlugins
        vars["BookingsM"] = bookingsM
        vars["Tab"] = self._activeTab
        vars["EventDate"] = formatDateTime(getAdjustedDate(nowutc(), self._conf))

        from MaKaC.plugins.Collaboration.handlers import RCCollaborationAdmin, RCCollaborationPluginAdmin, RCVideoServicesUser

        vars["UserIsAdmin"] = RCCollaborationAdmin.hasRights(self._user) or RCCollaborationPluginAdmin.hasRights(self._user, plugins=self._tabPlugins)

        hasCreatePermissions = {}
        videoServSupport = {}
        isAllowedToSearch = {}
        for plugin in plugins:
            pname = plugin.getName()
            hasCreatePermissions[pname] = RCVideoServicesUser.hasRights(user=self._user, pluginName=pname)
            videoServSupport[pname] = plugin.getOption("contactSupport").getValue() \
                if plugin.hasOption("contactSupport") else ""
            isAllowedToSearch[pname] = plugin.getOption("searchAllow").getValue() if plugin.hasOption("searchAllow")  \
                else False
        vars["HasCreatePermissions"] = hasCreatePermissions
        vars["VideoServiceSupport"] = videoServSupport
        vars["isAllowedToSearch"] = isAllowedToSearch

        singleBookingForms = {}
        multipleBookingForms = {}
        jsCodes = {}
        canBeNotified = {}

        for plugin in singleBookingPlugins:
            pluginId = plugin.getId()
            templateClass = CollaborationTools.getTemplateClass(pluginId, "WNewBookingForm")
            singleBookingForms[pluginId] = templateClass(self._conf, plugin.getId(), self._user).getHTML()

        for plugin in multipleBookingPlugins:
            pluginId = plugin.getId()
            templateClass = CollaborationTools.getTemplateClass(pluginId, "WNewBookingForm")
            newBookingFormHTML = templateClass(self._conf, plugin.getId(), self._user).getHTML()

            advancedTabClass = CollaborationTools.getTemplateClass(pluginId, "WAdvancedTab")
            if advancedTabClass:
                advancedTabClassHTML = advancedTabClass(self._conf, plugin.getId(), self._user).getHTML()
            else:
                advancedTabClassHTML = WConfModifCollaborationDefaultAdvancedTab(self._conf, plugin, self._user).getHTML()
            multipleBookingForms[pluginId] = (newBookingFormHTML, advancedTabClassHTML)

        for plugin in plugins:
            pluginId = plugin.getId()

            templateClass = CollaborationTools.getTemplateClass(pluginId, "WMain")
            jsCodes[pluginId] = templateClass(self._conf, plugin.getId(), self._user).getHTML()

            bookingClass = CollaborationTools.getCSBookingClass(pluginId)
            canBeNotified[pluginId] = bookingClass._canBeNotifiedOfEventDateChanges

        vars["SingleBookingForms"] = singleBookingForms
        vars["MultipleBookingForms"] = multipleBookingForms
        vars["JSCodes"] = jsCodes
        vars["CanBeNotified"] = canBeNotified

        return vars
Esempio n. 20
0
 def _hasAccess(self, aw):
     return RCCollaborationAdmin.hasRights(user=aw.getUser())
Esempio n. 21
0
 def _checkProtection(self):
     if not RCCollaborationAdmin.hasRights(self._getUser()):
         AdminService._checkProtection(self)
Esempio n. 22
0
 def fillManagementSideMenu(cls, obj, params={}):
     csbm = Catalog.getIdx("cs_bookingmanager_conference").get(obj._conf.getConference().getId())
     if csbm is not None and csbm.isCSAllowed(obj._rh.getAW().getUser()) and \
         (obj._conf.canModify(obj._rh.getAW()) or RCVideoServicesManager.hasRights(obj._rh._getUser(), obj._conf, 'any') or
             RCCollaborationAdmin.hasRights(obj._rh._getUser()) or RCCollaborationPluginAdmin.hasRights(obj._rh._getUser(), plugins='any')):
         params['Video Services'] = wcomponents.SideMenuItem(_("Video Services"), UHConfModifCollaboration.getURL(obj._conf, secure=obj._rh.use_https()))
Esempio n. 23
0
 def isAllowedToAccess(self, obj, params):
     user = params["user"]
     return Catalog.getIdx("cs_bookingmanager_conference").get(params["conf"].getId()).isPluginManagerOfAnyPlugin(user) or \
         RCCollaborationAdmin.hasRights(user=user) or RCCollaborationPluginAdmin.hasRights(user=user, plugins ='any')
Esempio n. 24
0
 def fillManagementSideMenu(cls, obj, params={}):
     csbm = Catalog.getIdx("cs_bookingmanager_conference").get(obj._conf.getConference().getId())
     if csbm is not None and csbm.isCSAllowed(obj._rh.getAW().getUser()) and \
         (obj._conf.canModify(obj._rh.getAW()) or RCVideoServicesManager.hasRights(obj._rh._getUser(), obj._conf, 'any') or
             RCCollaborationAdmin.hasRights(obj._rh._getUser()) or RCCollaborationPluginAdmin.hasRights(obj._rh._getUser(), plugins='any')):
         params['Video Services'] = wcomponents.SideMenuItem(_("Video Services"), UHConfModifCollaboration.getURL(obj._conf, secure=obj._rh.use_https()))