예제 #1
0
    def archiveTempBackgrounds(self, conf):
        """ Archives all the temporary backgrounds of this template.
        This method archives all of the temporary backgrounds of this template, which are
        stored in the form of filepath strings, in the __tempBackgroundsFilePaths dictionary,
        to a dictionary which stores LocalFile objects. The ids are copied, since there is a
        shared id counter for both dictionaries.
        After the archiving, the __tempBackgroundsFilePaths dictionary is reset to {}
        """

        for backgroundId, (filePath, bgPosition) in self.__tempBackgroundsFilePaths.iteritems():
            cfg = Config.getInstance()
            tempPath = cfg.getUploadedFilesSharedTempDir()
            filePath = os.path.join(tempPath, filePath)
            fileName = "background" + str(backgroundId) + "_t" + self.__id + "_c" + conf.id

            file = conference.LocalFile()
            file.setName( fileName )
            file.setDescription( "Background " + str(backgroundId) + " of the template " + self.__id + " of the conference " + conf.id )
            file.setFileName( fileName )
            file.setFilePath( filePath )

            file.setOwner( conf )
            file.setId( fileName )
            file.archive( conf._getRepository() )

            self.__backgrounds[backgroundId] = file
            self.__bgPositions[backgroundId] = bgPosition

        self.notifyModification()
        self.__tempBackgroundsFilePaths = {}
예제 #2
0
    def setTemplate(self, name, description, format, fd, id, extension = ".template"):
        """ Stores a template.
            There can be 1 template for any format.
        """

        cfg = Config.getInstance()
        tempPath = cfg.getUploadedFilesTempDir()
        tempFileName = tempfile.mkstemp( suffix="MaKaC.tmp", dir = tempPath )[1]
        f = open( tempFileName, "wb" )
        f.write( fd.read() )
        f.close()

        #id = self.getNewTemplateId()

        fileName = "Contribution_template_" + id + "_c" + self._conference.id + extension

        file = conference.LocalFile()
        file.setName( fileName )
        file.setDescription( "Paper reviewing template with id " + id + "with format: " + format + " of the conference " + self._conference.id )
        file.setFileName( fileName )

        file.setFilePath( tempFileName )
        file.setOwner( self._conference )
        file.setId( fileName )
        file.archive( self._conference._getRepository() )

        self._templates[id] = Template(id, self._conference, name, description, format, file)
        self.notifyModification()