当前位置: 首页>>代码示例>>Python>>正文


Python CrossLocationQueries.getReservations方法代码示例

本文整理汇总了Python中MaKaC.rb_location.CrossLocationQueries.getReservations方法的典型用法代码示例。如果您正苦于以下问题:Python CrossLocationQueries.getReservations方法的具体用法?Python CrossLocationQueries.getReservations怎么用?Python CrossLocationQueries.getReservations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MaKaC.rb_location.CrossLocationQueries的用法示例。


在下文中一共展示了CrossLocationQueries.getReservations方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: rebuildRoomReservationsIndex

# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getReservations [as 别名]
    def rebuildRoomReservationsIndex():
        from MaKaC.common.db import DBMgr
        from MaKaC.rb_location import CrossLocationDB
        from MaKaC.rb_room import RoomBase
        from MaKaC.plugins.RoomBooking.default.dalManager import DALManager
        from BTrees.OOBTree import OOBTree

        DBMgr.getInstance().startRequest()
        CrossLocationDB.connect()
        root = DALManager.root

        resvEx = ReservationBase()
        resvEx.isConfirmed = None
        allResvs = CrossLocationQueries.getReservations( resvExample = resvEx )
        print "There are " + str( len( allResvs ) ) + " resvs and pre-resvs to index..."
        c = 0
        
        root[_ROOM_RESERVATIONS_INDEX] = OOBTree()
        print "Room => Reservations Index branch created"
        
        for resv in allResvs:
            roomReservationsIndexBTree = root[_ROOM_RESERVATIONS_INDEX]
            resvs = roomReservationsIndexBTree.get( resv.room.id )
            if resvs == None:
                resvs = [] # New list of reservations for this room
                roomReservationsIndexBTree.insert( resv.room.id, resvs )
            resvs.append( resv )
            roomReservationsIndexBTree[resv.room.id] = resvs
            c += 1
            if c % 100 == 0:
                print c
        
        CrossLocationDB.commit()
        CrossLocationDB.disconnect()
        DBMgr.getInstance().endRequest()
开发者ID:davidmorrison,项目名称:indico,代码行数:37,代码来源:reservation.py

示例2: changeCreator

# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getReservations [as 别名]
def changeCreator(oldUser, newUser):
    dbi = DBMgr.getInstance()

    dbi.startRequest()
    Factory.getDALManager().connect()

    # check if the users exist
    if AvatarHolder().getById(oldUser) is None:
        print "There is no user with id %s"%oldUser
        return
    if AvatarHolder().getById(newUser) is None:
        print "There is no user with id %s"%newUser
        return

    resvEx = ReservationBase()
    resvEx.createdBy = oldUser

    allResv4OldUser = CrossLocationQueries.getReservations( resvExample = resvEx)

    if allResv4OldUser == []:
        print "No reservations for user %s"%oldUser
        return

    # resvs = ReservationBase.getReservations()
    # allResv4OldUser = [x for x in allResv if x.createdBy == oldUser]

    if type(allResv4OldUser) is not list:
        allResv4OldUser = [allResv4OldUser]

    # Modify reservations
    for r in allResv4OldUser:
        r.createdBy = newUser
        #print r.createdBy, r.id

    # Update index
    userReservationsIndexBTree = Reservation.getUserReservationsIndexRoot()

    newUserResvs = userReservationsIndexBTree.get( newUser )
    if newUserResvs == None:
        newUserResvs = [] # New list of reservations for this room
        userReservationsIndexBTree.insert( newUser, newUserResvs )
    newUserResvs.extend( allResv4OldUser )
    userReservationsIndexBTree[newUser] = newUserResvs[:]

    if userReservationsIndexBTree.has_key(oldUser):
        userReservationsIndexBTree.pop(oldUser)

    userReservationsIndexBTree._p_changed = 1

    # close DB connection
    Factory.getDALManager().commit()
    Factory.getDALManager().disconnect()
    dbi.endRequest()
    print "%s reservations have moved from creator %s to creator %s" % (len(allResv4OldUser), oldUser, newUser)
开发者ID:Ictp,项目名称:indico,代码行数:56,代码来源:changeCreatorToReservation.py

示例3: listResv4User

# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getReservations [as 别名]
def listResv4User(user):
    dbi = DBMgr.getInstance()

    dbi.startRequest()
    Factory.getDALManager().connect()

    resvEx = ReservationBase()
    resvEx.createdBy = user

    allResv = CrossLocationQueries.getReservations( resvExample = resvEx)
    print "User %s has %s resevations created by him/her"%(user, len(allResv))

    Factory.getDALManager().disconnect()
    dbi.endRequest()
开发者ID:Ictp,项目名称:indico,代码行数:16,代码来源:changeCreatorToReservation.py

示例4: runRoomDayIndexInit

# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getReservations [as 别名]
def runRoomDayIndexInit(dbi, withRBDB, prevVersion):
    """
    Initializing room+day => reservation index.
    """
    if not withRBDB:
        return

    root = DALManager().getRoot()
    if not root.has_key('RoomDayReservationsIndex'):
        root['RoomDayReservationsIndex'] = OOBTree()
        for i, resv in enumerate(CrossLocationQueries.getReservations()):
            resv._addToRoomDayReservationsIndex()
            if i % 1000 == 0:
                DALManager.commit()
        DALManager.commit()
开发者ID:ferhatelmas,项目名称:indico,代码行数:17,代码来源:migrate.py

示例5: runReservationNotificationMigration

# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getReservations [as 别名]
def runReservationNotificationMigration(dbi, withRBDB, prevVersion):
    """
    Migrate the reservation notification system.
    """
    if not withRBDB:
        return

    # Delete old start end notification data
    for i, resv in enumerate(CrossLocationQueries.getReservations()):
        if hasattr(resv, '_startEndNotification'):
            resv._startEndNotification = None
        if i % 1000 == 0:
            DALManager.commit()
    # Create start notification task
    Client().enqueue(RoomReservationTask(rrule.HOURLY, byminute=0, bysecond=0))
    DALManager.commit()
开发者ID:ferhatelmas,项目名称:indico,代码行数:18,代码来源:migrate.py

示例6: reservation

# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getReservations [as 别名]
    def reservation(self, locList):

        Factory.getDALManager().connect()

        resvEx = ReservationBase()
        resvEx.startDT = self._fromDT
        resvEx.endDT = self._toDT

        locList = filter(lambda loc: Location.parse(loc) is not None, locList)

        if self._fromDT or self._toDT:
            daysParam = (day.date() for day in rrule.rrule(rrule.DAILY, dtstart=self._fromDT, until=self._toDT))
        else:
            # slow!
            daysParam = None

        for loc in sorted(locList):
            resvs = CrossLocationQueries.getReservations(location=loc, resvExample=resvEx, days=daysParam)
            for obj in self._process(resvs, filter=self._resvFilter):
                yield obj

        Factory.getDALManager().disconnect()
开发者ID:VishrutMehta,项目名称:indico,代码行数:24,代码来源:http_api.py

示例7: len

# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getReservations [as 别名]
    if len(roomIDs) > 10:
        return "One can only export 10 rooms at most"

    #################### process ###################
    rooms = []
    for roomID in roomIDs:
        roomEx = Factory.newRoom()
        roomEx.id = roomID
        rooms.append(roomEx)

    resvEx = Factory.newReservation()
    resvEx.isCancelled = False
    resvEx.isRejected = False
    resvEx.startDT = datetime(sd.year, sd.month, sd.day, 0, 0)
    resvEx.endDT = datetime(ed.year, ed.month, ed.day, 23, 59)
    resvs = CrossLocationQueries.getReservations(location="CERN", resvExample=resvEx, rooms=rooms)
    collisions = []
    for resv in resvs:
        for p in resv.splitToPeriods(endDT=resvEx.endDT, startDT=resvEx.startDT):
            collisions.append(Collision( ( p.startDT, p.endDT ), resv ))

    of = params.get("of", "csv")
    if of == "xml":
        result = createXML(collisions, req)
    else:
        result = createCSV(collisions, req)

    Factory.getDALManager().disconnect()
    DBMgr.getInstance().endRequest()

    return result
开发者ID:arturodr,项目名称:indico,代码行数:33,代码来源:exportReservations.py

示例8: getObject

# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getReservations [as 别名]
    def getObject(self):
        """
        """
        if self.__resvID:
            from MaKaC.rb_location import CrossLocationQueries, Location

            obj = CrossLocationQueries.getReservations(resvID=self.__resvID, location=self.__location)
            return obj
        if self.__roomID:
            from MaKaC.rb_location import CrossLocationQueries, Location

            obj = CrossLocationQueries.getRooms(roomID=self.__roomID, location=self.__location)
            return obj
        if self.__categId:
            if not conference.CategoryManager().hasKey(self.__categId):
                raise errors.NoReportError(
                    _("There is no category with id '%s', or it has been deleted") % self.__categId
                )
            obj = conference.CategoryManager().getById(self.__categId)
            if self.__materialId:
                obj = obj.getMaterialById(self.__materialId)
            if self.__resId:
                obj = obj.getResourceById(self.__resId)
            return obj
        if not self.__confId:
            return None
        obj = conference.ConferenceHolder().getById(self.__confId)
        if obj == None:
            raise errors.NoReportError("The event you are trying to access does not exist or has been deleted")
        fr = materialFactories.ConfMFRegistry
        if self.__notifTplId:
            obj = obj.getAbstractMgr().getNotificationTplById(self.__notifTplId)
            return obj
        if self.__alarmId:
            obj = obj.getAlarmById(self.__alarmId)
            return obj
        if self.__trackId:
            obj = obj.getTrackById(self.__trackId)
            return obj
        if self.__menuLinkId:
            obj = obj.getDisplayMgr().getMenu().getLinkById(self.__menuLinkId)
            return obj
        if self.__contribTypeId:
            obj = obj.getContribTypeById(self.__contribTypeId)
            return obj
        if self.__abstractId:
            obj = obj.getAbstractMgr().getAbstractById(self.__abstractId)
            if obj == None:
                raise errors.NoReportError("The abstract you are trying to access does not exist or has been deleted")
            if self.__resId:
                return obj.getAttachmentById(self.__resId)
        if self.__registrantId:
            obj = obj.getRegistrantById(self.__registrantId)
            if obj == None:
                raise errors.NoReportError("The registrant you are trying to access does not exist or has been deleted")
            if self.__resId:
                return obj.getAttachmentById(self.__resId)
        if self.__sessionId:
            obj = obj.getSessionById(self.__sessionId)
            fr = materialFactories.SessionMFRegistry
            if obj == None:
                raise errors.NoReportError("The session you are trying to access does not exist or has been deleted")
        if self.__slotId:
            obj = obj.getSlotById(self.__slotId)
        if self.__contribId:
            obj = obj.getContributionById(self.__contribId)
            fr = materialFactories.ContribMFRegistry
            if obj == None:
                raise errors.NoReportError(
                    "The contribution you are trying to access does not exist or has been deleted"
                )
        if self.__reviewId:
            # obj must be a Contribution
            obj = obj.getReviewManager().getReviewById(self.__reviewId)
            if obj == None:
                raise errors.NoReportError("The review you are tring to access does not exist or has been deleted")
        if self.__subContribId and self.__contribId:
            obj = obj.getSubContributionById(self.__subContribId)
            fr = materialFactories.ContribMFRegistry
            if obj == None:
                raise errors.NoReportError(
                    "The subcontribution you are trying to access does not exist or has been deleted"
                )
        if not self.__materialId:
            return obj
        # first we check if it refers to a special type of material
        mat = None
        f = fr.getById(self.__materialId)
        if f:
            mat = f.get(obj)
        if not mat:
            mat = obj.getMaterialById(self.__materialId)
        if not self.__resId:
            return mat
        return mat.getResourceById(self.__resId)
开发者ID:arescope,项目名称:indico,代码行数:97,代码来源:locators.py


注:本文中的MaKaC.rb_location.CrossLocationQueries.getReservations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。