예제 #1
0
    def setUp(self):
        super(TestProtection, self).setUp()

        self._startDBReq()

        # Create a user
        ah = AvatarHolder()
        self._avatar = Avatar()
        self._avatar.setName("fake")
        self._avatar.setSurName("fake")
        self._avatar.setOrganisation("fake")
        self._avatar.setLang("en_GB")
        self._avatar.setEmail("*****@*****.**")
        self._avatar.setId("fake")
        ah.add(self._avatar)

        # Create a conference
        category = conference.CategoryManager().getById('0')
        self._conf = category.newConference(self._avatar)
        self._conf.setTimezone('UTC')
        sd = datetime(2011, 11, 1, 10, 0, tzinfo=timezone('UTC'))
        ed = datetime(2011, 11, 1, 18, 0, tzinfo=timezone('UTC'))
        self._conf.setDates(sd, ed)
        ch = ConferenceHolder()
        ch.add(self._conf)

        self._contrib1 = conference.Contribution()
        self._conf.addContribution(self._contrib1)

        self._session1 = conference.Session()
        self._conf.addSession(self._session1)

        self._session2 = conference.Session()
        self._conf.addSession(self._session2)

        self._contrib2 = conference.Contribution()
        self._session1.addContribution(self._contrib2)

        #Now we create the material (id=0) and attach it to the contrib
        self._material = conference.Material()
        self._contrib1.addMaterial(self._material)
        #Now we create a dummy file and attach it to the material
        filePath = os.path.join(os.getcwd(), "test.txt")
        fh = open(filePath, "w")
        fh.write("hola")
        fh.close()
        self._resource = conference.LocalFile()
        self._resource.setFilePath(filePath)
        self._resource.setFileName("test.txt")
        self._material.addResource(self._resource)

        self._stopDBReq()
예제 #2
0
    def setUp(self):
        super(TestProtection, self).setUp()

        with self._context("database"):
            # Create a conference
            category = conference.CategoryManager().getById('0')
            self._conf = category.newConference(self._dummy)
            self._conf.setTimezone('UTC')
            sd = datetime(2011, 11, 1, 10, 0, tzinfo=timezone('UTC'))
            ed = datetime(2011, 11, 1, 18, 0, tzinfo=timezone('UTC'))
            self._conf.setDates(sd, ed)
            ch = ConferenceHolder()
            ch.add(self._conf)

            self._contrib1 = conference.Contribution()
            self._conf.addContribution(self._contrib1)

            self._session1 = conference.Session()
            self._conf.addSession(self._session1)

            self._session2 = conference.Session()
            self._conf.addSession(self._session2)

            self._contrib2 = conference.Contribution()
            self._session1.addContribution(self._contrib2)

            #Now we create the material (id=0) and attach it to the contrib
            self._material = conference.Material()
            self._contrib1.addMaterial( self._material )
            #Now we create a dummy file and attach it to the material
            filePath = os.path.join( os.getcwd(), "test.txt" )
            fh = open(filePath, "w")
            fh.write("hola")
            fh.close()
            self._resource = conference.LocalFile()
            self._resource.setFilePath( filePath )
            self._resource.setFileName( "test.txt" )
            self._material.addResource( self._resource )
예제 #3
0
def getSessions(c, conf):
    cs = agenda.cursor(
    )  #craetes a cursor and selects all the seesion data for that conference
    cs.execute("select * from SESSION where ida = \'" + c[1] + "\'")
    s = cs.fetchone()
    #s[0]-ida, s[1]-ids, s[2]-schairman, s[3]-speriod1, s[4]-stime, s[5]-eperiod1, s[6]-etime, s[7]-stitle
    #s[8]-snbtalks, s[9]-slocation, s[10]-scem, s[11]-sstatus, s[12]-bld, s[13]-floor
    #s[14]-room, s[15]-broadcasturl, s[16]-cd, s[17]-md, s[18]-scomment
    while s != None:  #while there are more session
        if c[12] == "nosession" and c[5] == 1:
            ses = conf
        else:
            ses = conference.Session()  #add a new seesion to the conference
            slot = conference.SessionSlot(ses)
            if (s[3] == s[5]) and (
                    s[4] == s[6]
            ):  #if session has length of 0 set length to 1min so as not to raise exception. Results in sessions of 1min being created during mapping
                min = (s[6].seconds % 3600) / 60
                sd = datetime(s[3].year, s[3].month, s[3].day,
                              s[4].seconds / 3600, (s[4].seconds % 3600) / 60)
                ed = datetime(s[5].year, s[5].month, s[5].day,
                              s[6].seconds / 3600, min)
                ses.setStartDate(sd, 2)  #set the session properties
                ses.setEndDate(ed, 2)
                slot.setDates(sd, ed, 2)
            else:
                try:
                    sd = datetime(s[3].year, s[3].month, s[3].day,
                                  int(s[4].seconds / 3600),
                                  int((s[4].seconds % 3600) / 60))
                    ses.setStartDate(sd, 2)  #set the session properties
                    if (s[5] != None) and (s[6] != None):
                        ed = datetime(s[5].year, s[5].month, s[5].day,
                                      int(s[6].seconds / 3600),
                                      int((s[6].seconds % 3600) / 60))
                    else:
                        ed = datetime(s[3].year, s[3].month, s[3].day,
                                      int(s[4].seconds / 3600),
                                      int((s[4].seconds % 3600) / 60))
                    ses.setEndDate(ed, 2)
                    slot.setDates(sd, ed, 2)
                except (Exception, AttributeError, MaKaCError), e:
                    log("error adding session %s:%s, start or end date note found:%s"
                        % (s[0], s[1], e))
                    conf.removeSession(ses)
                    ses = None
                    return
            ses.addSlot(slot)
            ses.setTitle(s[7])
            #get_transaction().commit()
            if s[2] == None:
                username = ''
            else:
                username = s[2]
            if s[10] == None:
                uemail = ''
            else:
                uemail = s[10]
            if username == '' or uemail == '' or username.count(
                    " "
            ) >= max_white_space_in_names:  #if not full user details exist
                if username != '' or uemail != '':
                    if username != '':
                        convenertext = username
                    else:
                        convenertext = uemail
                    if uemail != '':
                        convenertext = "<a href=\"mailto:%s\">%s</a>" % (
                            uemail, convenertext)
                    ses.setConvenerText(convenertext)
            else:
                pw = genPW()  #generates random password
                convener = getUser(
                    username, uemail, '',
                    pw)  #creates a user representing the convener
                part = conference.SessionChair()
                part.setDataFromAvatar(convener)
                ses.addConvener(part)  #and adds the user to the list
            if s[11] == "close":
                ses.setClosed(True)
            if s[9] != "0--":
                loc = conference.CustomLocation()
                loc.setName(s[9])
                ses.setLocation(loc)
            if s[14] != "0--":
                loc = conference.CustomRoom()
                loc.setName(s[14])
                ses.setRoom(loc)
            if s[18]:
                ses.setDescription(s[18])
            conf.addSession(ses, 2)
        #gets the files associated with this session
        cf.execute(
            "select * from FILE, FILE_EVENT where FILE.id = fileID and eventID = \'"
            + s[0] + s[1] + "\'")
        f = cf.fetchone()
        while f != None:
            type = f[2]
            if type == "minutes" and not isinstance(ses,
                                                    conference.Conference):
                mi = ses.getMinutes()
                if not mi:
                    mi = ses.createMinutes()
                if f[5] == s[0] + s[1] + ".txt":
                    getMinutes(mi, f)
                else:
                    getFiles(mi, f)
            else:
                list = ses.getMaterialList()
                found = 0
                #if type in list get existing material
                for i in list:
                    if i.getTitle() == type:
                        found = 1
                        mat = i
                if found:
                    getFiles(mat, f)  #add resources to material
                else:  #if not then create new material with name 'type'
                    mat = conference.Material()
                    mat.setTitle(type)
                    ses.addMaterial(mat)
                    getFiles(mat, f)  #add resources to material
            f = cf.fetchone()  #get next file/resource
        addTalksToSession(s, ses,
                          slot)  #gets the talks associated with the session
        s = cs.fetchone()  #gets the next session