Ejemplo n.º 1
0
 def _process(self):
     wm = webcast.HelperWebcastManager.getWebcastManagerInstance()
     XG = xmlGen.XMLGen()
     XG.openTag("response")
     XG.openTag("status")
     XG.writeTag("value", "OK")
     XG.writeTag("message", "Returning all forthcoming webcasts")
     XG.closeTag("status")
     XG.openTag("webcasts")
     webcasts = wm.getForthcomingWebcasts()
     webcasts.sort(webcast.sortWebcastByDate)
     for wc in webcasts:
         if not wc in wm.whatsOnAir():
             if not wc.getEvent().isProtected():
                 self._printWebcast(wc, XG)
     XG.closeTag("webcasts")
     XG.closeTag("response")
     self._req.content_type = "text/xml"
     return XG.getXml()
Ejemplo n.º 2
0
def displayRSSList(res, req, tz):
    ch = ConferenceHolder()
    rss = xmlGen.XMLGen()
    rss.openTag('rss version="2.0"')
    rss.openTag("channel")
    rss.writeTag("title", "Indico RSS Feed")
    rss.writeTag("link", Config.getInstance().getBaseURL())
    rss.writeTag("description", "Export of some events stored in Indico")
    rss.writeTag("language", "en")
    rss.writeTag("pubDate", nowutc().strftime("%a, %d %b %Y %H:%M:%S %Z"))
    rss.writeTag("category", "")
    rss.writeTag("generator",
                 "CDS Indico %s" % Config.getInstance().getVersion())
    rss.writeTag("webMaster",
                 HelperMaKaCInfo.getMaKaCInfoInstance().getSupportEmail())
    rss.writeTag("ttl", "1440")
    for confId in res:
        c = ch.getById(confId)
        rss = displayRSSConf(c, rss, tz)
    rss.closeTag("channel")
    rss.closeTag("rss")
    return rss.getXml()
Ejemplo n.º 3
0
    def _process( self ):
        from datetime import datetime,timedelta
        from MaKaC.common.indexes import IndexesHolder

        self._req.content_type = "text/xml"
        XG = xmlGen.XMLGen()
        XG.openTag("response")

        now = startdt = enddt = datetime.now()
        today = startdt.date()
        startdt.replace( hour = 0, minute = 0)
        enddt.replace( hour = 23, minute = 59)

        calIdx = IndexesHolder().getById("calendar")

        nbEvtsToday = len(calIdx.getObjectsInDay(now))
        nbOngoingEvts = len(calIdx.getObjectsIn(now,now))

        self._createIndicator(XG, "nbEventsToday", "total number of events for today", nbEvtsToday)
        self._createIndicator(XG, "nbOngoingEvents", "total number of ongoing events", nbOngoingEvts)
        XG.closeTag("response")
        return XG.getXml()
Ejemplo n.º 4
0
    def _process(self):
        from MaKaC.rb_room import RoomBase
        from datetime import datetime, timedelta
        from MaKaC.rb_reservation import ReservationBase

        startdt = enddt = datetime.now()
        today = startdt.date()
        startdt.replace(hour=0, minute=0)
        enddt.replace(hour=23, minute=59)

        self._req.content_type = "text/xml"
        XG = xmlGen.XMLGen()
        XG.openTag("response")

        rooms = RoomBase.getRooms()
        nbRooms = len(rooms)
        nbPublicRooms = nbPrivateRooms = nbSemiPrivateRooms = 0
        for r in rooms:
            if not r.isReservable:
                nbPrivateRooms += 1
            elif not r.resvsNeedConfirmation:
                nbPublicRooms += 1
            else:
                nbSemiPrivateRooms += 1

        self._createIndicator(XG, "total", "total number of managed rooms",
                              nbRooms)
        self._createIndicator(XG, "public", "number of public rooms",
                              nbPublicRooms)
        self._createIndicator(XG, "semiprivate",
                              "number of semi-private rooms",
                              nbSemiPrivateRooms)
        self._createIndicator(XG, "private", "number of private rooms",
                              nbPrivateRooms)

        resvex = ReservationBase()
        resvex.isConfirmed = True
        resvex.isCancelled = False
        nbResvs = len(
            ReservationBase.getReservations(resvExample=resvex,
                                            days=[startdt.date()]))
        resvex.usesAVC = True
        nbAVResvs = len(
            ReservationBase.getReservations(resvExample=resvex,
                                            days=[startdt.date()]))
        resvex.needsAVCSupport = True
        resvex.needsAssistance = False
        nbAVResvsWithSupport = len(
            ReservationBase.getReservations(resvExample=resvex,
                                            days=[startdt.date()]))

        self._createIndicator(XG, "nbbookings",
                              "total number of bookings for today", nbResvs)
        self._createIndicator(
            XG, "nbvc",
            "number of remote collaboration bookings (video or phone conference)",
            nbAVResvs)
        self._createIndicator(
            XG, "nbvcsupport",
            "number of remote collaboration bookings with planned IT support",
            nbAVResvsWithSupport)

        XG.closeTag("response")
        return XG.getXml()
Ejemplo n.º 5
0
    def _process(self):
        if self._statusValue != "OK":
            return self._createResponse(self._statusValue, self._message)

        ih = indexes.IndexesHolder()
        calIdx = ih.getIndex("calendar")
        catIdx = ih.getIndex("category")
        ch = conference.ConferenceHolder()

        # A *preliminary* set of conference id's is created here
        # This set is constructed using indexes, without getting the Conference
        # objects from the DB.

        listOfSets = []

        if self._startDateAt != None:
            listOfSets.append(calIdx.getObjectsStartingInDay(
                self._startDateAt))

        if self._startDateFrom != None:
            listOfSets.append(
                calIdx.getObjectsStartingIn(self._startDateFrom,
                                            self._startDateTo))

        if self._endDateAt != None:
            listOfSets.append(calIdx.getObjectsEndingInDay(self._endDateAt))

        if self._endDateFrom != None:
            listOfSets.append(
                calIdx.getObjectsEndingIn(self._endDateFrom, self._endDateTo))

        if self._date != None:
            listOfSets.append(calIdx.getObjectsIn(self._date, self._date))

        if self._category != None:
            resultSet = Set()
            if type(self._category) is list:
                for i in self._category:
                    resultSet.union_update(catIdx.getItems(i))
            else:
                resultSet.union_update(catIdx.getItems(self._category))

            listOfSets.append(resultSet)

        if self._id != None:
            resultSet = Set()
            if type(self._id) is list:
                listOfSets.append(Set(self._id))
            else:
                listOfSets.append(Set([self._id]))

        prelimResult = listOfSets[0]
        for i in range(1, len(listOfSets)):
            prelimResult.intersection_update(listOfSets[i])

        result = Set()

        XG = xmlGen.XMLGen()
        XG.openTag("response")
        XG.openTag("status")
        XG.writeTag("value", "OK")
        XG.writeTag("message", "Returning search results")
        XG.closeTag("status")
        XG.openTag("event-list")
        for i in prelimResult:
            try:
                try:
                    c = ch.getById(i)
                except:
                    continue
                if self._author != None and not self._checkAuthor(
                        c, self._author):
                    continue
                if self._room != None and not self._checkRoom(c, self._room):
                    continue
                if self._startDateFrom != None:
                    if c.getStartDate() < self._startDateFrom or \
                      c.getStartDate() > self._startDateTo:
                        continue
                if self._startDateAt != None:
                    if c.getStartDate() != self._startDateAt:
                        continue
                if self._endDateFrom != None:
                    if c.getEndDate() < self._endDateFrom or \
                      c.getEndDate() > self._endDateTo:
                        continue
                if self._endDateAt != None:
                    if c.getEndDate() != self._endDateAt:
                        continue
                result.add(i)
                if self._format != "full":
                    self._printConference(c, XG)
                else:
                    XG.openTag("event")
                    og = outputGenerator(self.getAW(), XG)
                    og._confToXML(c, {})
                    XG.closeTag("event")

            except KeyError:
                continue

        XG.closeTag("event-list")
        XG.closeTag("response")
        self._req.content_type = "text/xml"

        return XG.getXml()