Example #1
0
 def getVars( self ):
     vars = wcomponents.WTemplated.getVars( self )
     
     plugins = self._tabPlugins
     singleBookingPlugins, multipleBookingPlugins = CollaborationTools.splitPluginsByAllowMultiple(plugins)
     CSBookingManager = self._conf.getCSBookingManager()
     
     bookingsS = {}
     for p in singleBookingPlugins:
         bookingList = CSBookingManager.getBookingList(filterByType = p.getName())
         if len(bookingList) > 0:
             bookingsS[p.getName()] = DictPickler.pickle(bookingList[0])
             
     bookingsM = DictPickler.pickle(CSBookingManager.getBookingList(
         sorted = True,
         notify = True,
         filterByType = [p.getName() for p in multipleBookingPlugins]))
     
     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.webinterface.rh.collaboration import RCCollaborationAdmin, RCCollaborationPluginAdmin
     vars["UserIsAdmin"] = RCCollaborationAdmin.hasRights(user = self._user) or RCCollaborationPluginAdmin.hasRights(user = self._user, plugins = self._tabPlugins)
     
     singleBookingForms = {}
     multipleBookingForms = {}
     JSCodes = {}
     canBeNotified = {}
     
     for plugin in singleBookingPlugins:
         pluginName = plugin.getName()
         templateClass = CollaborationTools.getTemplateClass(pluginName, "WNewBookingForm")
         singleBookingForms[pluginName] = templateClass(self._conf, pluginName, self._user).getHTML()
         
     for plugin in multipleBookingPlugins:
         pluginName = plugin.getName()
         templateClass = CollaborationTools.getTemplateClass(pluginName, "WNewBookingForm")
         multipleBookingForms[pluginName] = templateClass(self._conf, pluginName, self._user).getHTML()
     
     for plugin in plugins:
         pluginName = plugin.getName()
         
         templateClass = CollaborationTools.getTemplateClass(pluginName, "WMain")
         JSCodes[pluginName] = templateClass(pluginName, self._conf).getHTML()
         
         bookingClass = CollaborationTools.getCSBookingClass(pluginName)
         canBeNotified[pluginName] = bookingClass._canBeNotifiedOfEventDateChanges
         
     vars["SingleBookingForms"] = singleBookingForms    
     vars["MultipleBookingForms"] = multipleBookingForms
     vars["JSCodes"] = JSCodes
     vars["CanBeNotified"] = canBeNotified
     
     return vars
Example #2
0
    def _getAnswer(self):

        self.changeUserList(self._resource, self._newUserList)

        DictPickler.update(self._resource, self._newProperties)
        return self._resource.fossilize({"MaKaC.conference.Link": ILinkFossil,
                                        "MaKaC.conference.LocalFile": ILocalFileExtendedFossil})
Example #3
0
 def _getAnswer( self):
     
     if self._info == None:
         return UserGetPersonalInfo(self._params, self._aw.getIP(), self._aw.getSession()).process()
     
     pInfo = self._target.getPersonalInfo()
     
     DictPickler.update(pInfo, self._info)
     return DictPickler.pickle(pInfo)
Example #4
0
    def _getAnswer(self):
        """
        Updates the material with the new properties
        """

        self.changeUserList(self._material, self._newUserList)

        DictPickler.update(self._material, self._newProperties)
        return DictPickler.pickle(self._material)
Example #5
0
    def _getAnswer(self):
        """
        Updates the material with the new properties
        """

        self.changeUserList(self._material, self._newUserList)

        DictPickler.update(self._material, self._newProperties)            
        return DictPickler.pickle(self._material)
Example #6
0
    def __addPresenters(self, subcontrib):

        # add each presenter
        for presenterValues in self._presenters:

            # magically update a new ContributionParticipation with JSON data, using the DictPickler
            presenter = conference.SubContribParticipation()
            DictPickler.update(presenter, presenterValues)

            subcontrib.newSpeaker(presenter)
Example #7
0
    def _getAnswer(self):

        if self._info == None:
            return UserGetPersonalInfo(self._params, self._aw.getIP(),
                                       self._aw.getSession()).process()

        pInfo = self._target.getPersonalInfo()

        DictPickler.update(pInfo, self._info)
        return DictPickler.pickle(pInfo)
Example #8
0
    def _getAnswer(self):

        results = search.searchPeople(surName = self._params.get("surName", ""),
                               name = self._params.get("name", ""),
                               organisation = self._params.get("organisation", ""),
                               email = self._params.get("email", ""),
                               group = self._params.get("group", ""),
                               conferenceId = self._params.get("conferenceId", None),
                               exactMatch = self._params.get("exactMatch", False),
                               searchExt = self._params.get("searchExt", False))
        results["people"] = sorted([DictPickler.pickle(human) for human in results.get("people", [])], cmp=SearchUsersGroups._cmpUsers)
        results["groups"] = sorted([DictPickler.pickle(group) for group in results.get("groups", [])], cmp=SearchUsersGroups._cmpGroups)
        return results
Example #9
0
    def _getAnswer( self ):
        """ Calls _handleGet() or _handleSet() on the derived classes, in order to make it happen. Provides
            them with self._value.
            
            When calling _handleGet(), it will return the value to return.
            When calling _handleSet(), it will return:
            -either self._value if there were no problems
            -either a FieldModificationWarning object (pickled) if there are warnings to give to the user
        """

        # fetch the 'value' parameter (default for text)
        if self._params.has_key('value'):
            self._value = self._params['value']
        else:
            # None if not passed
            self._value = None

        if self._value == None:
            return self._handleGet()
        else:
            setResult = self._handleSet()
            if isinstance(setResult, Warning):
                return DictPickler.pickle(ResultWithWarning(self._value, setResult))
            else:
                return self._value
Example #10
0
    def _getResult(self, module):

        if module.hasObject(self._obj):
            raise ServiceError("ERR-O3", "Object is already in the list!")

        module.addObject(self._obj, self._objWeight, datetime.timedelta(days=self._objDelta))

        return DictPickler.pickle(module.getObjectList()[-1])
Example #11
0
    def _handleGet(self):
        contributions = self._conf.getContributionList()

        filter = {}

        # filtering if the active user is a referee: he can only see his own contribs
        isOnlyReferee = (
            RCReferee.hasRights(self)
            and not RCPaperReviewManager.hasRights(self)
            and not self._conf.canModify(self.getAW())
        )
        if isOnlyReferee:
            filter["referee"] = self._getUser()
        elif self._showWithReferee:
            filter["referee"] = "any"
        else:
            filter["referee"] = None

        if self._showWithEditor:
            filter["editor"] = "any"
        else:
            filter["editor"] = None
        if self._showWithReviewer:
            filter["reviewer"] = "any"
        else:
            filter["reviewer"] = None

        # note by David: I added "if self._selTypes..." and the other ifs after this line,
        # in order to make the recording request load contributions work
        # but, it may break the paper reviewing module -> assign contributions filter
        if self._selTypes:
            filter["type"] = self._selTypes
        if self._selTracks:
            filter["track"] = self._selTracks
        if self._selSessions:
            filter["session"] = self._selSessions
        if self._poster:
            filter["poster"] = self._poster

        filterCrit = ContributionsReviewingFilterCrit(self._conf, filter)
        sortingCrit = contribFilters.SortingCriteria(["number"])

        if self._selTypes:
            filterCrit.getField("type").setShowNoValue(self._typeShowNoValue)
        if self._selTracks:
            filterCrit.getField("track").setShowNoValue(self._trackShowNoValue)
        if self._selSessions:
            filterCrit.getField("session").setShowNoValue(self._sessionShowNoValue)
        if self._poster:
            filterCrit.getField("poster").setShowNoValue(self._posterShowNoValue)

        filterCrit.getField("referee").setShowNoValue(not isOnlyReferee)

        f = filters.SimpleFilter(filterCrit, sortingCrit)
        contributions = f.apply(contributions)

        return DictPickler.pickle(contributions)
Example #12
0
    def _handleGet(self):
        contributions = self._conf.getContributionList()

        filter = {}

        #filtering if the active user is a referee: he can only see his own contribs
        isOnlyReferee = RCReferee.hasRights(self) \
                        and not RCPaperReviewManager.hasRights(self) \
                        and not self._conf.canModify(self.getAW())
        if isOnlyReferee:
            filter["referee"] = self._getUser()
        elif self._showWithReferee:
            filter["referee"] = "any"
        else:
            filter["referee"] = None

        if self._showWithEditor:
            filter["editor"] = "any"
        else:
            filter["editor"] = None
        if self._showWithReviewer:
            filter["reviewer"] = "any"
        else:
            filter["reviewer"] = None

        #note by David: I added "if self._selTypes..." and the other ifs after this line,
        #in order to make the recording request load contributions work
        #but, it may break the paper reviewing module -> assign contributions filter
        if self._selTypes:
            filter["type"] = self._selTypes
        if self._selTracks:
            filter["track"] = self._selTracks
        if self._selSessions:
            filter["session"] = self._selSessions
        if self._poster:
            filter["poster"] = self._poster

        filterCrit = ContributionsReviewingFilterCrit(self._conf, filter)
        sortingCrit = contribFilters.SortingCriteria(["number"])

        if self._selTypes:
            filterCrit.getField("type").setShowNoValue(self._typeShowNoValue)
        if self._selTracks:
            filterCrit.getField("track").setShowNoValue(self._trackShowNoValue)
        if self._selSessions:
            filterCrit.getField("session").setShowNoValue(
                self._sessionShowNoValue)
        if self._poster:
            filterCrit.getField("poster").setShowNoValue(
                self._posterShowNoValue)

        filterCrit.getField("referee").setShowNoValue(not isOnlyReferee)

        f = filters.SimpleFilter(filterCrit, sortingCrit)
        contributions = f.apply(contributions)

        return DictPickler.pickle(contributions)
Example #13
0
    def getBookings(self, indexName, viewBy, orderBy, minKey, maxKey,
                    tz = 'UTC', onlyPending = False, conferenceId = None, categoryId = None,
                    pickle = False, dateFormat = None, page = None, resultsPerPage = None):
        
        if onlyPending:
            indexName += "_pending"
            
        reverse = orderBy == "descending"

        try:
            index = self.getIndex(indexName)
            totalInIndex = index.getCount()
            
            if categoryId and not CategoryManager().hasKey(categoryId) or conferenceId and not ConferenceHolder().hasKey(conferenceId):
                finalResult = QueryResult([], 0, 0, totalInIndex, 0)
            else:
                if viewBy == "conferenceTitle":
                    items, nBookings = index.getBookingsByConfTitle(minKey, maxKey, conferenceId, categoryId)
                elif viewBy == "conferenceStartDate":
                    items, nBookings = index.getBookingsByConfDate(minKey, maxKey, conferenceId, categoryId)
                else:
                    items, nBookings = index.getBookingsByDate(viewBy, minKey, maxKey, tz, conferenceId, categoryId, dateFormat)
                    
                if reverse:
                    items.reverse()
                    
                
                nGroups = len(items)
                    
                if page:
                    page = int(page)
                    if resultsPerPage:
                        resultsPerPage = int(resultsPerPage)
                    else:
                        resultsPerPage = 10
        
                    nPages = nGroups / resultsPerPage
                    if nGroups % resultsPerPage > 0:
                        nPages = nPages + 1
                    
                    if page > nPages:
                        finalResult = QueryResult([], 0, 0, totalInIndex, nPages)
                    else:
                        finalResult = QueryResult(items[(page - 1) * resultsPerPage : page * resultsPerPage], nBookings, nGroups, totalInIndex, nPages)
                        
                else:
                    finalResult = QueryResult(items, nBookings, nGroups, totalInIndex, 0)
            
        except KeyError:
            Logger.get("VideoServ").warning("Tried to retrieve index with name " + indexName + " but the index did not exist. Maybe no bookings have been added to it yet")
            finalResult = QueryResult([], 0, 0, 0)
            
        if pickle:
            return DictPickler.pickle(finalResult, tz)
        else:
            return finalResult
Example #14
0
 def _getAnswer( self):
     
     users = []
     
     userDict = self._target.getPersonalInfo().getBasket().getUsers()
     
     for user in userDict.itervalues():
         users.append(DictPickler.pickle(user))
         
     return users
Example #15
0
    def _getAnswer(self):

        users = []

        userDict = self._target.getPersonalInfo().getBasket().getUsers()

        for user in userDict.itervalues():
            users.append(DictPickler.pickle(user))

        return users
Example #16
0
 def _getAnswer(self):
     """
     Provides the list of material classes, based on the target
     resource (conference, session, contribution, etc...)
     """
     matList = {}
             
     for mat in self._target.getAllMaterialList():
         matList[mat.getId()] = DictPickler.pickle(mat)
         
     return matList            
Example #17
0
 def _getAnswer(self):
     newsModule=ModulesHolder().getById("news")
     item=newsModule.getNewsItemById(self._id)
     if item:
         item.setTitle(self._title)
         item.setType(self._type)
         item.setContent(self._content)
         tz = self.getAW().getUser().getTimezone() #this is an admin service so user is always logged in (or _checkProtection detects it before)
         return DictPickler.pickle(item, tz)
     else:
         raise Exception("News item does not exist")
Example #18
0
    def _getAnswer(self):
        """
        Provides the list of material classes, based on the target
        resource (conference, session, contribution, etc...)
        """
        matList = {}

        for mat in self._target.getAllMaterialList():
            matList[mat.getId()] = DictPickler.pickle(mat)

        return matList
Example #19
0
 def _getAnswer(self):
     """
     Creates the material class, and sets its properties
     """
     
     mats = self._target.getMaterialList()
     
     for m in mats:
         if m.getTitle() == self._matName:                
             raise ServiceError("ERR-M1", _("A material with this same name already exists"))
     
     mat = conference.Material()
     mat.setTitle(self._matName)
     mat.setDescription(self._matDescription)
     self._target.addMaterial( mat )
     return DictPickler.pickle(mat)
Example #20
0
    def _getAnswer(self):
        """
        Creates the material class, and sets its properties
        """

        mats = self._target.getMaterialList()

        for m in mats:
            if m.getTitle() == self._matName:
                raise ServiceError(
                    "ERR-M1",
                    _("A material with this same name already exists"))

        mat = conference.Material()
        mat.setTitle(self._matName)
        mat.setDescription(self._matDescription)
        self._target.addMaterial(mat)
        return DictPickler.pickle(mat)
Example #21
0
 def _getAnswer(self):
     return DictPickler.pickle(self._CSBookingManager.checkBookingStatus(self._bookingId),
                               timezone = self._conf.getTimezone())
Example #22
0
 def getVars( self ):
     vars = wcomponents.WTemplated.getVars( self )
     vars["Conference"] = self._conf
     vars["CSBM"] = self._conf.getCSBookingManager()
     vars["Favorites"] = DictPickler.pickle(self._user.getPersonalInfo().getBasket().getUsers())
     return vars
Example #23
0
 def _getResult(self, module):
     return DictPickler.pickle(module.getObjectList());
Example #24
0
 def _getAnswer(self):
     """
     Lists the users that allowed to access the material
     """
     return DictPickler.pickle(self._resource.getAllowedToAccessList())
Example #25
0
 def _getAnswer(self):
     return DictPickler.pickle(self._CSBookingManager.acceptBooking(self._bookingId),
                               timezone = self._conf.getTimezone())
Example #26
0
 def _getAnswer(self):
     return DictPickler.pickle(
         self._CSBookingManager.acceptBooking(self._bookingId), timezone=self._conf.getTimezone()
     )
Example #27
0
            raise RequestError("ERR-R3", "Error parsing json request.", e)

        if "id" in requestBody:
            responseBody["id"] = requestBody["id"]

        result = invokeMethod(str(requestBody["method"]), requestBody.get("params", []), req)

        # serialize result
        try:
            responseBody["result"] = result
        except Exception, e:
            raise ProcessError("ERR-P1", "Error during serialization.")

    except CausedError, e:

        errorInfo = DictPickler.pickle(e);

        if isinstance(e, NoReportError):
            # NoReport errors (i.e. not logged in) shouldn't be logged
            pass
        else:
            Logger.get('rpc').exception('Service request failed. Request text:\r\n%s\r\n\r\n' % str(requestText))

            if requestBody:
                errorInfo["requestInfo"] = {"method": str(requestBody["method"]),
                                            "params": requestBody.get("params", [])}
                Logger.get('rpc').debug('Arguments: %s' % errorInfo['requestInfo'])


        responseBody["error"] = errorInfo
Example #28
0
 def _getAnswer(self):
     return DictPickler.pickle(self._CSBookingManager.changeBooking(self._bookingId, self._bookingParams),
                               timezone = self._conf.getTimezone())
Example #29
0
 def _getAnswer(self):
     return DictPickler.pickle(self._target.getPersonalInfo())
Example #30
0
 def _getAnswer(self):
     return DictPickler.pickle(
         self._CSBookingManager.createTestBooking(bookingParams=self._bookingParams),
         timezone=self._conf.getTimezone(),
     )
Example #31
0
 def _getAnswer(self):
     return DictPickler.pickle(self._CSBookingManager.rejectBooking(self._bookingId, self._reason),
                               timezone = self._conf.getTimezone())
Example #32
0
 def _getAnswer(self):
     """
     Lists the users that allowed to access the material
     """
     return DictPickler.pickle(self._resource.getAllowedToAccessList())
Example #33
0
 def _getAnswer(self):
     return DictPickler.pickle(self._CSBookingManager.createTestBooking(bookingParams = self._bookingParams),
                               timezone = self._conf.getTimezone())
Example #34
0
 def _getAnswer( self):            
     return DictPickler.pickle(self._target.getPersonalInfo())
Example #35
0
 def _getAnswer(self):
     return DictPickler.pickle(
         self._CSBookingManager.changeBooking(self._bookingId, self._bookingParams),
         timezone=self._conf.getTimezone(),
     )
Example #36
0
    def _getAnswer(self):
        resList = {}

        for resource in self._material.getResourceList():
            resList[resource.getId()] = DictPickler.pickle(resource)
        return resList
Example #37
0
 def _getAnswer(self):
     return DictPickler.pickle(
         self._CSBookingManager.checkBookingStatus(self._bookingId), timezone=self._conf.getTimezone()
     )
Example #38
0
    def _getAnswer(self):

        self.changeUserList(self._resource, self._newUserList)

        DictPickler.update(self._resource, self._newProperties)
        return DictPickler.pickle(self._resource)
Example #39
0
 def _getAnswer(self):
     return DictPickler.pickle(
         self._CSBookingManager.rejectBooking(self._bookingId, self._reason), timezone=self._conf.getTimezone()
     )
Example #40
0
 def _getAnswer(self):
     """
     Provides the list of material classes, based on the target
     resource (conference, session, contribution, etc...)
     """            
     return DictPickler.pickle(self._material)
Example #41
0
 def _getAnswer(self):
     newsModule=ModulesHolder().getById("news")
     ni=NewsItem(self._title, self._content, self._type)
     newsModule.addNewsItem(ni)
     tz = self.getAW().getUser().getTimezone() #this is an admin service so user is always logged in (or _checkProtection detects it before)
     return DictPickler.pickle(ni, tz)
Example #42
0
 def _getAnswer(self):
     """
     Provides the list of material classes, based on the target
     resource (conference, session, contribution, etc...)
     """
     return DictPickler.pickle(self._material)
Example #43
0
 def _getAnswer(self):                   
     resList = {}        
             
     for resource in self._material.getResourceList():                        
         resList[resource.getId()] = DictPickler.pickle(resource)
     return resList
Example #44
0
    def _process(self, rh, params):
        
        # We will need to pickle the data back into JSON
        from MaKaC.common.PickleJar import DictPickler
        
        errorList=[]
        user = rh.getAW().getUser()
        try:
            owner = self._target
            title = owner.getTitle()
            if type(owner) == Conference:
                ownerType = "event"
            elif type(owner) == Session:
                ownerType = "session"
            elif type(owner) == Contribution:
                ownerType = "contribution"
            elif type(owner) == SubContribution:
                ownerType = "subcontribution"
            else:
                ownerType = ""
            text = " in %s %s" % (ownerType,title)
        except:
            owner = None
            text = ""

        errorList=self._getErrorList()
        file = self._file
        link = self._link        
        resource = None
        
        if self._uploadType == "file":
            if len(errorList)==0:
                mat = self._getMaterial()
                
                if mat == None:
                    errorList.append("Unknown material");
                else:
                    resource = LocalFile()
                    resource.setFileName(file["fileName"])
                    resource.setName(resource.getFileName())
                    resource.setFilePath(file["filePath"])
                    resource.setDescription(self._description)
                    mat.addResource(resource)
                    #apply conversion
                    if self._topdf and fileConverter.CDSConvFileConverter.hasAvailableConversionsFor(os.path.splitext(resource.getFileName())[1].strip().lower()):
                        fileConverter.CDSConvFileConverter.convert(resource.getFilePath(), "pdf", mat)
                    if not type(self._target) is Category:
                        self._target.getConference().getLogHandler().logAction({"subject":"Added file %s%s" % (file["fileName"],text)},"Files",user)
                    # in case of db conflict we do not want to send the file to conversion again
                    self._topdf = False
    
            if len(errorList) > 0:
                status = "ERROR"
                info = errorList
            else:
                status = "OK"
                info = DictPickler.pickle(resource)
                info['material'] = mat.getId();
        
        elif self._uploadType == "link":
            if len(errorList)==0:
                mat = self._getMaterial()
                if mat == None:
                    mat = Material()
                    mat.setTitle(link["matType"])
                    self._target.addMaterial( mat )
                resource = Link()
                resource.setURL(link["url"])
                resource.setName(resource.getURL())
                resource.setDescription(self._description)
                mat.addResource(resource)
                if not type(self._target) is Category:
                    self._target.getConference().getLogHandler().logAction({"subject":"Added link %s%s" % (resource.getURL(),text)},"Files",user)
            
                status = "OK"
                info = DictPickler.pickle(resource)
                info['material'] = mat.getId();
            else:
                status = "ERROR"
                info = errorList
        
        else:
            status = "ERROR"
            info = "Unknown upload type"
          
        # hackish, because of mime types. Konqueror, for instance, would assume text if there were no tags,
        # and would try to open it
        from MaKaC.services.interface.rpc import json
        return "<html><head></head><body>"+json.encode({'status': status, 'info': info})+"</body></html>"
Example #45
0
    def _getAnswer(self):

        self.changeUserList(self._resource, self._newUserList)

        DictPickler.update(self._resource, self._newProperties)
        return DictPickler.pickle(self._resource)
Example #46
0
        if "id" in requestBody:
            responseBody["id"] = requestBody["id"]

        result = invokeMethod(str(requestBody["method"]),
                              requestBody.get("params", []), req)

        # serialize result
        try:
            responseBody["result"] = result
        except Exception, e:
            raise ProcessError("ERR-P1", "Error during serialization.")

    except CausedError, e:

        errorInfo = DictPickler.pickle(e)

        if isinstance(e, NoReportError):
            # NoReport errors (i.e. not logged in) shouldn't be logged
            pass
        else:
            Logger.get('rpc').exception(
                'Service request failed. Request text:\r\n%s\r\n\r\n' %
                str(requestText))

            if requestBody:
                errorInfo["requestInfo"] = {
                    "method": str(requestBody["method"]),
                    "params": requestBody.get("params", [])
                }
                Logger.get('rpc').debug('Arguments: %s' %