Esempio n. 1
0
    def _handleSet(self):
        room = self._target.getRoom()

        if room == None:
            room = conference.CustomRoom()
            self._target.setRoom(room)

        room.setName(self._value['room'])

        loc = self._target.getLocation()
        if not loc:
            loc = conference.CustomLocation()
            self._target.setLocation(loc)

        loc.setName(self._value['location'])
        loc.setAddress(self._value['address'])
Esempio n. 2
0
                l = conference.CustomLocation()
                c.setLocation(l)

            if l.getName() != newLocation:
                l.setName(newLocation)
                changed = True

            l.setAddress(confData.get("locationAddress", ""))

        if newRoom.strip() == "":
            r = None
            c.setRoom(None)
        else:
            r = c.getRoom()
            if not r:
                r = conference.CustomRoom()
                c.setRoom(r)

            if r.getName() != newRoom:
                r.setName(newRoom)
                r.retrieveFullName(newLocation)
                changed = True

        if changed:
            new_data = {
                'location': l.name if l else '',
                'address': l.address if l else '',
                'room': r.name if r else ''
            }
            if old_data != new_data:
                signals.event.data_changed.send(c,
Esempio n. 3
0
def addTalksToSession(s, ses, slot):
    ct = agenda.cursor(
    )  #creates a cursor and gets all the Talks associated with this session
    ct.execute("select * from TALK where ids = \'" + s[1] + "\' and ida = \'" +
               s[0] + "\'")
    t = ct.fetchone()  #selects the first talk from the list
    #t[0]-ida, t[1]-ids, t[2]-idt, t[3]-ttitle, t[4]-tspeaker, t[5]-tday, t[6]-tcomment, t[7]-location
    #t[8]-bld, t[9]-floor, t[10]-room, t[11]-broadcasturl, t[12]-type, t[13]-cd, t[14]-md, t[15]-category
    #t[16]-stime, t[17]-repno, t[18]-affiliation, t[19]-duration, t[20]-email
    while t != None:  #if there is another talk
        if t[5] != None:
            if t[12] == 2:  #if talk is of type break
                br = schedule.BreakTimeSchEntry()
                br.setTitle(t[3])  #sets the break details
                br.setDescription(t[6])
                br.setColor("#90C0F0")
                br.setStartDate(
                    datetime(t[5].year, t[5].month, t[5].day,
                             int(t[16].seconds / 3600),
                             int((t[16].seconds % 3600) / 60), 2))
                try:
                    br.setDuration(int(t[19].seconds / 3600),
                                   int((t[19].seconds % 3600) / 60))
                except Exception, e:
                    log("error setting break end time %s-%s-%s: %s" %
                        (t[0], t[1], t[2], e))
                    #get_transaction().abort()
                slot.getSchedule().addEntry(br, 2)  #create a new break
                slot.getSchedule().reSchedule()
            else:
                talk = ses.newContribution(
                    id="%s%s" %
                    (t[1], t[2]))  #adds a contribution to the session
                if t[15] != '':
                    title = "<b>%s</b><br>%s" % (t[15], t[3])
                else:
                    title = t[3]
                talk.setTitle(title)  #sets the contribution details
                talk.setDescription(t[6])
                #talk.setCategory(t[15]) #sets category header for talks.  Mainly used in seminars for the week of.  Not in MaKaC
                if t[7] != "0--":
                    loc = conference.CustomLocation()
                    loc.setName(t[7])
                #get_transaction().commit()
                pw = genPW()  #generates random password
                if t[4] == None:
                    username = ''
                else:
                    username = t[4]
                if t[20] == None:
                    uemail = ''
                else:
                    uemail = t[20]
                if t[18]:
                    aff = t[18]
                else:
                    aff = ''
                if username == '' or uemail == '' or username.count(
                        " "
                ) >= max_white_space_in_names:  #if not full user details exist
                    if username != '' or uemail != '':
                        if username != '':
                            speakertext = username
                        else:
                            speakertext = uemail
                        if uemail != '':
                            speakertext = "<a href=\"mailto:%s\">%s</a>" % (
                                uemail, speakertext)
                        if aff != '':
                            speakertext = "%s (%s)" % (speakertext, aff)
                        talk.setSpeakerText(speakertext)
                else:
                    speaker = getUser(
                        username, uemail, aff,
                        pw)  #creates a user representing the speaker
                    part = conference.ContributionParticipation()
                    part.setDataFromAvatar(speaker)
                    talk.addPrimaryAuthor(part)
                    talk.addSpeaker(part)  #and adds the user to the list
                if t[10] != "0--":
                    talk.setLocation(loc)
                    loc = conference.CustomRoom()
                    loc.setName(t[10])
                    talk.setRoom(loc)
                if t[5] != None:
                    talk.setStartDate(
                        datetime(t[5].year, t[5].month, t[5].day,
                                 int(t[16].seconds / 3600),
                                 int((t[16].seconds % 3600) / 60)), 2)
                talk.setDuration(t[19].seconds / 3600,
                                 (t[19].seconds % 3600) / 60)
                #gets the files associated with this talk
                cf.execute(
                    "select * from FILE, FILE_EVENT where FILE.id = fileID and eventID = \'"
                    + t[0] + t[1] + t[2] + "\'")
                f = cf.fetchone()
                while f != None:
                    type = f[2]
                    if type == "minutes":
                        mi = talk.getMinutes()
                        if not mi:
                            mi = talk.createMinutes()
                        if f[5] == t[0] + t[1] + t[2] + ".txt":
                            getMinutes(mi, f)
                        else:
                            getFiles(mi, f)
                    else:
                        list = talk.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)
                            talk.addMaterial(mat)
                            getFiles(mat, f)  #add resources to material
                    f = cf.fetchone()  #get next file/resource
                getSubTalks(
                    t,
                    talk)  #call to the function which would map the subtalks
                sch = slot.getSchedule()
                try:
                    sch.addEntry(talk.getSchEntry(), 2)
                except Exception, e:
                    log("%s-%s-%s: %s" % (t[0], t[1], t[2], e))
Esempio n. 4
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
Esempio n. 5
0
def getAgenda():
    print "migrating..."
    log("start getAgenda")
    cc = agenda.cursor()  #creates a new cursor to the database
    listcat = getAllSubCategories("171")
    strlistcat = "','".join(listcat)
    #cc.execute("select * from AGENDA where id='a052023'")
    #cc.execute("select * from AGENDA where fid in ('%s') and YEAR(cd)=2004 order by id"%strlistcat)#gets the AGENDAS
    #cc.execute("select * from AGENDA where fid in ('%s') and id>='' order by id"%strlistcat)#gets the AGENDAS
    #cc.execute("select * from AGENDA where fid = '296'")#gets the AGENDAS
    cc.execute(
        "select * from AGENDA where id > 'a015' and id < 'a02' order by id"
    )  #gets the AGENDAS
    #cc.execute("select * from AGENDA where id like 'a00%' and cd > '2000-12-01' ")#gets the AGENDAS
    #cc.execute("select * from AGENDA where id like 'a02%' and id >'a021094' order by id")
    #cc.execute("select * from AGENDA where id>='a045146' order by id")
    c = cc.fetchone()  #gets the next AGENDA
    cate = agenda.cursor()  #creates a cursor to get the LEVEL informaion
    #c[0]-title, c[1]-id, c[2]-stdate, c[3]-endate, c[4]-location, c[5]-nbsession, c[6]-chairman, c[7]-cem
    #c[8]-status, c[9]-an, c[10]-cd, c[11]-md, c[12]-stylesheet, c[13]-format, c[14]-confidentiality
    #c[15]-apassword, c[16]-repno, c[17]-fid, c[18]-acomments, c[19]-keywords, c[20]-visibility
    #c[21]-bld, c[22]-floor, c[23]-room, c[24]-stime, c[25]-etime
    #get CERN domain
    dh = domain.DomainHolder()
    CDom = None
    for dom in dh.getList():
        if dom.getName().upper() == "CERN":
            CDom = dom
    if not CDom:
        CDom = domain.Domain()
        CDom.setName("CERN")
        CDom.setDescription("CERN domain")
        CDom.addFiltersFromStr("128.141;128.142;137.138;192.91;194.12;192.16")
        dh.add(CDom)
        db.DBMgr.getInstance().commit()
    error = False
    ch = conference.ConferenceHolder()
    while c != None:
        #db.DBMgr.getInstance().startRequest()
        try:
            log("add conference : %s" % c[1])
            cate.execute(
                "select * from LEVEL where uid = \'" + c[17] +
                "\'")  #gets the name of the Category the conf belongs in
            catWanted = conference.Category(
            )  #creates Category that the AGENDA should belong to
            level = cate.fetchone()  #sets the category properties
            catWanted.setName(level[3])
            catWanted.setDescription(level[6])
            catWanted.setOrder(level[12])
            catWanted.setVisibility(level[9])
            catWanted.setId(level[0])
            category = getCat(
                catWanted, level[1], level[7]
            )  #checks to see if this category already exists - if not creates it
            if category == None:  #Conference is in a category to delete: don't add
                log("Conference %s not added, it's inside a 'to delete' category"
                    % c[1])
                db.DBMgr.getInstance().abort()
                c = cc.fetchone()
                continue
            user = getUser('CDS Agenda', '*****@*****.**', '',
                           '')  #creates a user representing creator
            try:
                cd = datetime(c[10].year, c[10].month, c[10].day)
            except:
                cd = datetime(1999, 1, 1)
            try:
                md = datetime(c[11].year, c[11].month, c[11].day)
            except:
                md = datetime(1999, 1, 1)
            try:
                conf = ch.getById(c[1])
            except:
                pass
            conf = category.newConference(
                user, c[1], cd, md)  #creates new Conference to map onto
            # update counter
            #year = c[1][1:3]
            #count = c[1][3:]
            #if count == "":
            #    count = 0
            #counterName = "CONFERENCE%s" % year
            #idxs = ch._getTree("counters")
            #if not idxs.has_key(counterName):
            #    idxs[counterName] = Counter()
            #idxs[counterName].sync(int(count))
            if c[8] == "close":
                conf.setClosed(True)
            conf.setTitle(c[0])
            conf.setDescription(c[18])
            if str(c[20]) == '0' or str(c[20]) == '':
                visibility = 999
            else:
                visibility = int(c[20])
            conf.setVisibility(visibility)
            startDate = datetime(c[2].year, c[2].month, c[2].day,
                                 int(c[24].seconds / 3600),
                                 int((c[24].seconds % 3600) / 60))
            endDate = None
            if c[3] != None:
                endDate = datetime(c[3].year, c[3].month, c[3].day,
                                   int(c[25].seconds / 3600),
                                   int((c[25].seconds % 3600) / 60))
            if not endDate or endDate <= startDate:
                endDate = datetime(c[2].year, c[2].month, c[2].day,
                                   int(c[24].seconds / 3600),
                                   int((c[24].seconds % 3600) / 60))
            conf.setDates(startDate, endDate)
            if c[4] != "0--":
                loc = conference.CustomLocation()
                loc.setName(c[4])
                conf.setLocation(loc)
        except (MaKaCError, AttributeError), e:
            log("Error : %s : conference not added" % e)
            c = cc.fetchone()  #gets the next conference
            error = True
        if not error:
            pw = genPW()  #generates random password
            if c[6] == None or c[6] == '\xa0':
                username = ''
            else:
                username = c[6]
            if c[7] == None:
                uemail = ''
            else:
                uemail = c[7]
            if uemail == '' or username.count(
                    " "
            ) >= max_white_space_in_names:  #if not full user details exist
                if username != '' or uemail != '':
                    if username != '':
                        chairtext = username
                    else:
                        chairtext = uemail
                    if uemail != '':
                        chairtext = "<a href=\"mailto:%s\">%s</a>" % (
                            uemail, chairtext)
                    conf.setChairmanText(chairtext)
            else:
                chair = getUser(username, uemail, '',
                                pw)  #creates the chairman user
                conf.addChair(chair)
            setType(c[12], conf.getId())  #sets the format of the agenda
            if c[13] == 'olist':  #facility to cope with this not in MaKaC
                pass  #set the format of talks to ordered list (A,B,C etc) rather than times
            if c[23] != "0--":
                loc = conference.CustomRoom()
                loc.setName(c[23])
                conf.setRoom(loc)
            cf = agenda.cursor()
            #gets the files associated with this conference
            cf.execute(
                "select * from FILE, FILE_EVENT where FILE.id = fileID and eventID = \'"
                + c[1] + "\'")
            f = cf.fetchone()  #gets the first file form the list
            while f != None:
                list = conf.getMaterialList()
                type = f[2]
                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)
                    conf.addMaterial(mat)
                    getFiles(mat, f)  #add resources to material
                f = cf.fetchone()  #get next file/resource
            if c[12] == "nosession":  #if there are no sessions look for contributions that go directly onto conference
                addToConf(c, conf)
            else:
                getSessions(
                    c, conf)  #gets the sessions belonging to this conference
            confId = conf.getId()
            # ACCESS CONTROL
            if c[14] == 'password':  #if conference is password protected creates and access user
                conf.setAccessKey(c[15])  #set the access password
                conf.setProtection(1)  #makes the conference restricted access
                #conf.grantAccess(colin)#grants access rights to me (for testing reasons)
            elif c[14] == 'cern-only':
                conf.requireDomain(CDom)
                log("added CERN domain")
            # MODIFICATION RIGHTS
            conf.setModifKey(c[9])  #add modification key
            log("Conference added : MaKaC ID : %s" % confId)
            # DEFAULT STYLE
            if c[12] in styles.keys():
                displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
                    conf).setDefaultStyle(styles[c[12]])
            else:
                displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
                    conf).setDefaultStyle("standard")
            c = cc.fetchone()  #gets the next conference
        else:
            error = False
            db.DBMgr.getInstance().commit()