示例#1
0
 def _getAnswer(self):
     dh = domain.DomainHolder()
     d = dh.getById(self._domainId)
     if self._add:
         self._target.requireDomain(d)
     elif not self._add:
         self._target.freeDomain(d)
示例#2
0
文件: admins.py 项目: belokop/indico
 def getVars(self):
     vars = wcomponents.WTemplated.getVars(self)
     dh = domain.DomainHolder()
     letters = dh.getBrowseIndex()
     vars["browseIndex"] = i18nformat("""
     <span class="nav_border"><a href='' class="nav_link" onClick="document.browseForm.letter.disable=1;document.browseForm.submit();return false;">_("clear")</a></span>"""
                                      )
     if self._letter == "all":
         vars["browseIndex"] += """
     [all] """
     else:
         vars["browseIndex"] += i18nformat("""
     <span class="nav_border"><a href='' class="nav_link" onClick="document.browseForm.letter.value='all';document.browseForm.submit();return false;">_("all")</a></span> """
                                           )
     for letter in letters:
         if self._letter == letter:
             vars["browseIndex"] += """\n[%s] """ % letter
         else:
             vars[
                 "browseIndex"] += """\n<span class="nav_border"><a href='' class="nav_link" onClick="document.browseForm.letter.value='%s';document.browseForm.submit();return false;">%s</a></span> """ % (
                     escape(letter, True), letter)
     vars["browseResult"] = ""
     if self._letter not in [None, ""]:
         if self._letter != "all":
             res = dh.matchFirstLetter(self._letter)
         else:
             res = dh.getValuesToList()
         res.sort(key=lambda x: x.getName().lower())
         vars["browseResult"] = WHTMLDomainList(vars, res).getHTML()
     return vars
示例#3
0
 def _process( self ):
     params = self._getRequestParams()
     if ("selectedDomain" in params) and (len(params["selectedDomain"])!=0):
         dh = domain.DomainHolder()
         for domId in self._normaliseListParam( params["selectedDomain"] ):
             self._target.freeDomain( dh.getById( domId ) )
     self._redirect( urlHandlers.UHMaterialModifAC.getURL( self._target ) )
示例#4
0
 def _process(self):
     d = domain.Domain()
     _DomainUtils.setDomainValues(d, self._getRequestParams())
     if d.getName() != "":
         dh = domain.DomainHolder()
         dh.add(d)
         self._redirect(urlHandlers.UHDomainDetails.getURL(d))
     else:
         self._redirect(urlHandlers.UHDomains.getURL())
示例#5
0
文件: admins.py 项目: belokop/indico
 def getVars(self):
     vars = wcomponents.WTemplated.getVars(self)
     vars["createDomainURL"] = urlHandlers.UHNewDomain.getURL()
     vars["nbDomains"] = domain.DomainHolder().getLength()
     vars["browseDomains"] = WBrowseDomains(self._params.get(
         "letter", None)).getHTML(vars)
     vars["browseDomainsURL"] = urlHandlers.UHDomains.getURL()
     vars["searchDomainsURL"] = urlHandlers.UHDomains.getURL()
     vars["domains"] = ""
     if self._criteria:
         domainList = self._performSearch(self._criteria)
         vars["domains"] = WHTMLDomainList(vars, domainList).getHTML()
     return vars
示例#6
0
 def __init__(self, params):
     domId = params.get("domainId", "")
     if domId == "":
         raise errors.MaKaCError(_("domain id not set"))
     dh = domain.DomainHolder()
     self._dom = dh.getById(domId)
示例#7
0
文件: admins.py 项目: belokop/indico
 def _performSearch(self, criteria):
     dh = domain.DomainHolder()
     res = dh.match(criteria)
     return res
示例#8
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()