Ejemplo n.º 1
0
    def _process( self ):
        params = self._getRequestParams()
        #set default variables
        if not self._reqParams.has_key("showDate"):
            self._reqParams["showDate"] = "all"
        if not self._reqParams.has_key("showSession"):
            self._reqParams["showSession"] = "all"
        if not self._reqParams.has_key("detailLevel"):
            self._reqParams["detailLevel"] = "contribution"
        #get default/selected view
        view = "static"
        wf = self.getWebFactory()
        if wf != None:
            type = self.getWebFactory().getId()
        else:
            type = "conference"
        styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
        if self._reqParams.has_key("view"):
            view = self._reqParams["view"]
        else:
            view = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).getDefaultStyle()
            # if no default view was attributed, then get the configuration default
            if view == "" or not styleMgr.existsStyle(view):
                view =styleMgr.getDefaultStyleForEventType( type )
                displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).setDefaultStyle( view )
        isLibxml = True
        warningText = ""
        try:
            import lxml
        except:
            isLibxml = False

        # create the html factory
        if type == "conference":
            if params.get("ovw", False):
                p = conferences.WPConferenceDisplay( self, self._target )
            else:
                self._page = None
                intPagesMgr=internalPagesMgr.InternalPagesMgrRegistery().getInternalPagesMgr(self._target)
                for page in intPagesMgr.getPagesList():
                    if page.isHome():
                        self._page = page
                if not self._page:
                    p = conferences.WPConferenceDisplay( self, self._target )
                else:
                    p = conferences.WPInternalPageDisplay(self,self._target, self._page)
        elif view in styleMgr.getXSLStyles():
            if not isLibxml:
                warningText = "lxml needs to be installed if you want to use a stylesheet-driven display - switching to static display"
            self._responseUtil.content_type = 'text/xml'
            p = conferences.WPXSLConferenceDisplay( self, self._target, view, type, self._reqParams )
        elif view != "static":
            p = conferences.WPTPLConferenceDisplay( self, self._target, view, type, self._reqParams )
        else:
            if wf != None:
                p = wf.getConferenceDisplayPage( self, self._target, self._reqParams )
            else:
                p = conferences.WPConferenceDisplay( self, self._target )

        return warningText + p.display(**params)
Ejemplo n.º 2
0
def changeCatStyle(cat):
    for subcat in cat.getSubCategoryList():
        currentStyle = subcat.getDefaultStyle("meeting")
        subcat.setDefaultStyle("meeting", "lhcb_meeting")
        logfile.write("cat %s: %s" % (subcat.getId(), currentStyle))
        changeCatStyle(subcat)
    for conf in cat.getConferenceList():
        currentStyle = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
            conf).getDefaultStyle()
        displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
            conf).setDefaultStyle("lhcb_meeting")
        logfile.write("\t\t\tconf %s: %s" % (conf.getId(), currentStyle))
Ejemplo n.º 3
0
 def _checkParams(self, params):
     RHConferenceTimeTable._checkParams(self, params)
     self._showSessions = self._normaliseListParam(
         params.get("showSessions", []))
     if "all" in self._showSessions:
         self._showSessions.remove("all")
     self._showDays = self._normaliseListParam(params.get("showDays", []))
     if "all" in self._showDays:
         self._showDays.remove("all")
     self._sortingCrit = None
     if params.has_key("sortBy") and params["sortBy"].strip() != "":
         self._sortingCrit = contribFilters.SortingCriteria(
             [params.get("sortBy", "number").strip()])
     self._pagesize = params.get('pagesize', 'A4')
     self._fontsize = params.get('fontsize', 'normal')
     try:
         self._firstPageNumber = int(params.get('firstPageNumber', '1'))
     except ValueError:
         self._firstPageNumber = 1
     self._showSpeakerAffiliation = False
     if params.has_key("showSpeakerAffiliation"):
         self._showSpeakerAffiliation = True
     # Keep track of the used layout for getting back after cancelling
     # the export.
     self._view = params.get(
         "view",
         displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
             self._target).getDefaultStyle())
Ejemplo n.º 4
0
    def getVars(self):
        vars = wcomponents.WTemplated.getVars( self )
        vars["logo"] = ""
        if self._conf.getLogo():
            vars["logo"] = "<img src=\"%s\" alt=\"%s\" border=\"0\">"%(vars["logoURL"], self._conf.getTitle())
        vars["confTitle"] = self._conf.getTitle()
        vars["displayURL"] = urlHandlers.UHConferenceDisplay.getURL(self._conf)
        vars["imgConferenceRoom"] = Config.getInstance().getSystemIconURL( "conferenceRoom" )
        tzUtil = timezoneUtils.DisplayTZ(self._aw,self._conf)
        tz = tzUtil.getDisplayTZ()
        adjusted_sDate = self._conf.getStartDate().astimezone(timezone(tz))
        adjusted_eDate = self._conf.getEndDate().astimezone(timezone(tz))

        vars["confDateInterval"] = i18nformat("""_("from") %s _("to") %s (%s)""")%(format_date(adjusted_sDate, format='long'), format_date(adjusted_eDate, format='long'), tz)

        if self._conf.getStartDate().strftime("%d%B%Y") == \
                self._conf.getEndDate().strftime("%d%B%Y"):
            vars["confDateInterval"] = format_date(adjusted_sDate, format='long') + " (" + tz + ")"
        elif self._conf.getStartDate().month == self._conf.getEndDate().month:
            vars["confDateInterval"] = "%s-%s %s %s"%(adjusted_sDate.day, adjusted_eDate.day, format_date(adjusted_sDate, format='MMMM yyyy'), tz)
        vars["body"] = self._body
        vars["confLocation"] = ""
        if self._conf.getLocationList():
            vars["confLocation"] =  self._conf.getLocationList()[0].getName()
            vars["supportEmail"] = ""
        if self._conf.getSupportInfo().hasEmail():
            mailto = quoteattr("""mailto:%s?subject=%s"""%(self._conf.getSupportInfo().getEmail(), urllib.quote( self._conf.getTitle() ) ))
            vars["supportEmail"] =  i18nformat("""<a href=%s class="confSupportEmail"><img src="%s" border="0" alt="email">  _("support")</a>""")%(mailto, Config.getInstance().getSystemIconURL("mail") )
        format = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getFormat()
        vars["bgColorCode"] = format.getFormatOption("titleBgColor")["code"]
        vars["textColorCode"] = format.getFormatOption("titleTextColor")["code"]
        return vars
Ejemplo n.º 5
0
 def getVars(self):
     vars = wcomponents.WTemplated.getVars( self )
     vars["logo"] = ""
     if self._conf.getLogo():
         vars["logo"] = "<img src=\"%s\" alt=\"%s\" border=\"0\">"%(vars["logoURL"], self._conf.getTitle())
     vars["confTitle"] = self._conf.getTitle()
     vars["displayURL"] = urlHandlers.UHConferenceDisplay.getURL(self._conf)
     vars["imgConferenceRoom"] = Config.getInstance().getSystemIconURL( "conferenceRoom" )
     #################################
     # Fermi timezone awareness      #
     #################################
     vars["confDateInterval"] = i18nformat("""_("from") %s _("to") %s""")%(format_date(self._conf.getStartDate(), format='long'), format_date(self._conf.getEndDate(), format='long'))
     if self._conf.getStartDate().strftime("%d%B%Y") == \
             self._conf.getEndDate().strftime("%d%B%Y"):
         vars["confDateInterval"] = format_date(self._conf.getStartDate(), format='long')
     elif self._conf.getStartDate().month == self._conf.getEndDate().month:
         vars["confDateInterval"] = "%s-%s %s"%(self._conf.getStartDate().day, self._conf.getEndDate().day, format_date(self._conf.getStartDate(), format='MMMM yyyy'))
     #################################
     # Fermi timezone awareness(end) #
     #################################
     vars["body"] = self._body
     vars["confLocation"] = ""
     if self._conf.getLocationList():
         vars["confLocation"] =  self._conf.getLocationList()[0].getName()
         vars["supportEmail"] = ""
     if self._conf.getSupportInfo().hasEmail():
         mailto = quoteattr("""mailto:%s?subject=%s"""%(self._conf.getSupportInfo().getEmail(), urllib.quote( self._conf.getTitle() ) ))
         vars["supportEmail"] =  _("""<a href=%s class="confSupportEmail"><img src="%s" border="0" alt="email"> %s</a>""")%(mailto,
                                                     Config.getInstance().getSystemIconURL("mail"),
                                                     self._conf.getSupportInfo().getCaption())
     format = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getFormat()
     vars["bgColorCode"] = format.getFormatOption("titleBgColor")["code"]
     vars["textColorCode"] = format.getFormatOption("titleTextColor")["code"]
     return vars
Ejemplo n.º 6
0
 def _getMenuItems(self):
     menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
     for link in menu.getEnabledLinkList():
         if link.isVisible():
             if isinstance(link, displayMgr.PageLink):
                 self._getInternalPage(link)
             elif not isinstance(link, displayMgr.Spacer):
                 self._getMenuSystemItem(link)
Ejemplo n.º 7
0
 def confDisplaySMShow(cls, obj, params):
     obj._collaborationOpt = obj._sectionMenu.getLinkByName("collaboration")
     csbm = Catalog.getIdx("cs_bookingmanager_conference").get(obj._conf.getConference().getId())
     if csbm is not None and (not csbm.hasBookings() or not csbm.isCSAllowed()):
         if obj._collaborationOpt is None:
             displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(obj._conf.getConference(), True) # updating menu
             obj._collaborationOpt = obj._sectionMenu.getLinkByName("collaboration")
         obj._collaborationOpt.setVisible(False)
Ejemplo n.º 8
0
 def _process(self):
     im = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getImagesManager()
     if im.getPic(self._picId):
         pic = im.getPic(self._picId).getLocalFile()
         return send_file(pic.getFileName(), pic.getFilePath(), pic.getFileType())
     else:
         self._responseUtil.status = 404
         return WPError404(self, urlHandlers.UHConferenceDisplay.getURL(self._conf)).display()
Ejemplo n.º 9
0
 def _create_home(self):
     # get default/selected view
     styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
     view = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._rh._target).getDefaultStyle()
     # if no default view was attributed, then get the configuration default
     if view == "" or not styleMgr.existsStyle(view) or view in styleMgr.getXSLStyles():
         view = styleMgr.getDefaultStyleForEventType(self._eventType)
     p = WPTPLStaticConferenceDisplay(self._rh, self._rh._target, view, self._eventType, self._rh._reqParams)
     self._html = p.display(**self._rh._getRequestParams())
Ejemplo n.º 10
0
 def _checkProtection(self):
     conferenceDisplay.RHConferenceBaseDisplay._checkProtection(self)
     if not self._conf.hasEnabledSection(
             "regForm"
     ) or not displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
             self._conf).getMenu().getLinkByName("registrants").isEnabled():
         raise NoReportError(
             "The registrants list page was disabled by the conference managers"
         )
Ejemplo n.º 11
0
 def _process( self ):
     defStyle = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).getDefaultStyle()
     if defStyle in ["", "static", "parallel"]:
         p = conferences.WPConferenceTimeTable( self, self._target )
         return p.display( **self._getRequestParams() )
     else:
         url = urlHandlers.UHConferenceOtherViews.getURL( self._conf )
         url.addParam("view", defStyle)
         self._redirect(url)
Ejemplo n.º 12
0
 def _process(self):
     #set default variables
     if not self._reqParams.has_key("showDate"):
         self._reqParams["showDate"] = "all"
     if not self._reqParams.has_key("showSession"):
         self._reqParams["showSession"] = "all"
     if not self._reqParams.has_key("detailLevel"):
         self._reqParams["detailLevel"] = "contribution"
     #get default/selected view
     view = "standard"
     type = "conference"
     styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager(
     )
     isLibxml = True
     try:
         import lxml
     except:
         isLibxml = False
     if self._reqParams.has_key("view"):
         view = self._reqParams["view"]
     else:
         view = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
             self._target).getDefaultStyle()
         # if no default view was attributed, then get the configuration default
         if view == "":
             view = styleMgr.getDefaultStyleForEventType(type)
             displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
                 self._target).setDefaultStyle(view)
     # create the html factory
     if view in styleMgr.getXSLStyles() and isLibxml:
         p = conferences.WPXSLConferenceDisplay(self, self._target, view,
                                                type, self._reqParams)
     elif view != "static":
         p = conferences.WPTPLConferenceDisplay(self, self._target, view,
                                                type, self._reqParams)
     else:
         p = conferences.WPMeetingTimeTable(self, self._target, "parallel",
                                            "meeting", self._reqParams)
     # generate the html
     if view == "xml" and self._reqParams.get('fr') == 'no':
         self._responseUtil.content_type = 'text/xml'
     return p.display()
Ejemplo n.º 13
0
 def _process(self):
     sm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
         self._conf).getStyleManager()
     css = sm.getLocalCSS()
     if css:
         return send_file(css.getFileName(),
                          css.getFilePath(),
                          mimetype='text/css',
                          no_cache=False,
                          conditional=True)
     return ""
Ejemplo n.º 14
0
    def removeVideoServicesLinksFromCore(conf):
        """
        Video Services migration remove from core
        """

        # Update Menu Links
        menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(conf).getMenu()
        if menu:
            link = menu.getLinkByName("collaboration")
            if link:
                link.setURLHandler(urlHandlers.UHCollaborationDisplay)
Ejemplo n.º 15
0
    def _handleSet(self):
        curType = self._target.getType()
        newType = self._value
        if newType != "" and newType != curType:
            import MaKaC.webinterface.webFactoryRegistry as webFactoryRegistry
            wr = webFactoryRegistry.WebFactoryRegistry()
            factory = wr.getFactoryById(newType)
            wr.registerFactory(self._target, factory)

            styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance(
            ).getStyleManager()

            dispMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
                self._target)
            dispMgr.setDefaultStyle(
                styleMgr.getDefaultStylesheetForEventType(newType))
Ejemplo n.º 16
0
def conferenceMigration1_2(dbi, prevVersion):
    """
    Tasks: 1. Migrates old AbstractField to new AbstractField subclasses
           2. Add download e-ticket PDF link to the menu
    """
    def updateAbstractFields(conf):
        """
        Migrates old AbstractField to new AbstractField subclasses
        """

        afm = conf.getAbstractMgr().getAbstractFieldsMgr()
        for index, field in enumerate(afm._fields):
            if field is not None:
                if type(field) != AbstractField:
                    continue  # Database already contains AbstractField objects created on v1.2.
                params = {}
                params["id"] = field._id
                params["type"] = field._type
                params["caption"] = field._caption
                params["isMandatory"] = field._isMandatory
                try:
                    params["maxLength"] = field._maxLength
                except:
                    pass
                try:
                    params["limitation"] = field._limitation
                except:
                    pass
                afm._fields[index] = AbstractField.makefield(params)
                afm._p_changed = 1
        # Delete all None items in the field list
        afm._fields = filter(None, afm._fields)

    cdmr = displayMgr.ConfDisplayMgrRegistery()
    ch = ConferenceHolder()
    i = 0

    for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'):

        updateAbstractFields(conf)
        # Add download e-ticket PDF link to the menu:
        _fixDefaultStyle(conf, cdmr)

        if i % 10000 == 9999:
            dbi.commit()
        i += 1
    dbi.commit()
Ejemplo n.º 17
0
    def updateSupport(conf):
        #################################################################
        #Moving support info fields from conference to a dedicated class:
        #################################################################

        dMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(conf)
        caption = email = telephone = ""

        if hasattr(dMgr, "_supportEmailCaption"):
            caption = dMgr._supportEmailCaption
            del dMgr._supportEmailCaption
        if hasattr(conf, "_supportEmail"):
            email = conf._supportEmail
            del conf._supportEmail

        supportInfo = SupportInfo(conf, caption, email, telephone)
        conf.setSupportInfo(supportInfo)
Ejemplo n.º 18
0
def conferenceMigration1_2(dbi, withRBDB, prevVersion):
    """
    Tasks: 1. Removing Video Services from core
           2. Migrates old AbstractField to new AbstractField subclasses
           3. Add download e-ticket PDF link to the menu
    """
    def removeVideoServicesLinksFromCore(conf):
        """
        Video Services migration remove from core
        """

        # Update Menu Links
        menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
            conf).getMenu()
        if menu:
            link = menu.getLinkByName("collaboration")
            if link:
                link.setURLHandler(urlHandlers.UHCollaborationDisplay)

    def updateAbstractFields(conf):
        """
        Migrates old AbstractField to new AbstractField subclasses
        """

        afm = conf.getAbstractMgr().getAbstractFieldsMgr()
        for index, field in enumerate(afm._fields):
            if field is not None:
                if type(field) != AbstractField:
                    continue  # Database already contains AbstractField objects created on v1.2.
                params = {}
                params["id"] = field._id
                params["type"] = field._type
                params["caption"] = field._caption
                params["isMandatory"] = field._isMandatory
                try:
                    params["maxLength"] = field._maxLength
                except:
                    pass
                try:
                    params["limitation"] = field._limitation
                except:
                    pass
                afm._fields[index] = AbstractField.makefield(params)
                afm._p_changed = 1
        # Delete all None items in the field list
        afm._fields = filter(None, afm._fields)

    cdmr = displayMgr.ConfDisplayMgrRegistery()
    ch = ConferenceHolder()
    i = 0

    for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'):

        removeVideoServicesLinksFromCore(conf)
        updateAbstractFields(conf)
        # Add download e-ticket PDF link to the menu:
        _fixDefaultStyle(conf, cdmr)

        if i % 10000 == 9999:
            dbi.commit()
        i += 1
    dbi.commit()
Ejemplo n.º 19
0
                signals.event.data_changed.send(c,
                                                attr='location',
                                                old=old_data,
                                                new=new_data)

        emailstr = setValidEmailSeparators(confData.get("supportEmail", ""))

        if (emailstr != "") and not validMail(emailstr):
            raise FormValuesError(
                "One of the emails specified or one of the separators is invalid"
            )

        c.getSupportInfo().setEmail(emailstr)
        c.getSupportInfo().setCaption(confData.get("supportCaption",
                                                   "Support"))
        displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(c).setDefaultStyle(
            confData.get("defaultStyle", ""))
        if c.getVisibility() != confData.get("visibility", 999):
            c.setVisibility(confData.get("visibility", 999))
        curType = c.getType()
        newType = confData.get("eventType", "")
        if newType != "" and newType != curType:
            wr = webFactoryRegistry.WebFactoryRegistry()
            factory = wr.getFactoryById(newType)
            wr.registerFactory(c, factory)
            dispMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(c)
            styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance(
            ).getStyleManager()
            dispMgr.setDefaultStyle(
                styleMgr.getDefaultStyleForEventType(newType))

    @staticmethod
Ejemplo n.º 20
0
def moveLogoToDisplayMgr(conf):
    log("changing logo for conf %s"%conf.getId())
    im = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(conf).getImagesManager()
    im._logo = conf._logo
Ejemplo n.º 21
0
                r.retrieveFullName(newLocation)
                changed = True

        if changed:
            c._notify('placeChanged')

        emailstr = setValidEmailSeparators(confData.get("supportEmail", ""))

        if (emailstr != "") and not validMail(emailstr):
            raise FormValuesError(
                "One of the emails specified or one of the separators is invalid"
            )

        c.setSupportEmail(emailstr)
        displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
            c).setSupportEmailCaption(confData.get("supportCaption",
                                                   "Support"))
        displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(c).setDefaultStyle(
            confData.get("defaultStyle", ""))
        if c.getVisibility() != confData.get("visibility", 999):
            c.setVisibility(confData.get("visibility", 999))
        curType = c.getType()
        newType = confData.get("eventType", "")
        if newType != "" and newType != curType:
            wr = webFactoryRegistry.WebFactoryRegistry()
            factory = wr.getFactoryById(newType)
            wr.registerFactory(c, factory)
            dispMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(c)
            styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance(
            ).getStyleManager()
            dispMgr.setDefaultStyle(
Ejemplo n.º 22
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()
Ejemplo n.º 23
0
def conferenceMigration(dbi, withRBDB, prevVersion):
    """
    Adding missing attributes to conference objects and children
    """

    cdmr = displayMgr.ConfDisplayMgrRegistery()
    ch = ConferenceHolder()
    i = 0

    from97 = prevVersion < parse_version("0.98b1")

    # migrating from <=0.97.1 requires smaller granularity
    for (level, obj) in console.conferenceHolderIterator(ch, deepness='subcontrib' if from97 else 'event'):
        # only for conferences
        if level == 'event':

            if from97:
                # handle sessions, that our iterator ignores
                for session in obj.getSessionList():
                    _fixAccessController(session)

                if hasattr(obj, '_Conference__alarmCounter'):
                    raise Exception("Conference Object %s (%s) seems to have been "
                                    "already converted" % (obj, obj.id))

                existingKeys = obj.alarmList.keys()
                existingKeys.sort()
                nstart = int(existingKeys[-1]) + 1 if existingKeys else 0
                obj._Conference__alarmCounter = Counter(nstart)

                # For each conference, take the existing tasks and
                # convert them to the new object classes.
                _convertAlarms(obj)

            # convert registration form's "Personal Data" section to new format
            obj.getRegistrationForm()._convertPersonalData()

            # For each conference, fix the default style
            _fixDefaultStyle(obj, cdmr)

        if from97:
            _fixAccessController(obj,
                                 fixSelf=(level != 'subcontrib'))

            # Convert RegistrationSessions to RegistrantSessions
            if isinstance(obj, Conference):
                for reg in obj.getRegistrants().itervalues():
                    if reg._sessions and \
                           isinstance(reg._sessions[0], RegistrationSession):
                        reg._sessions = [RegistrantSession(ses, reg) \
                                         for ses in reg._sessions]

        if i % 1000 == 999:
            dbi.commit()
            if withRBDB and from97:
                DALManager.commit()

        i += 1

    dbi.commit()
    if withRBDB and from97:
        DALManager.commit()
Ejemplo n.º 24
0
 def _getAnswer(self):
     im = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
         self._conf).getImagesManager()
     im.removePic(self._id)
Ejemplo n.º 25
0
 def _handleGet(self):
     dispManReg = displayMgr.ConfDisplayMgrRegistery()
     return dispManReg.getDisplayMgr(self._target).getDefaultStyle()
Ejemplo n.º 26
0
 def _handleSet(self):
     dispManReg = displayMgr.ConfDisplayMgrRegistery()
     dispManReg.getDisplayMgr(self._target).setDefaultStyle(self._value)