Beispiel #1
0
def slotLocationMigration(dbi, withRBDB, prevVersion):
    """
    Add missing location info to slots of a session that contains location or room
    """

    ch = ConferenceHolder()
    i = 0

    for (level, obj) in console.conferenceHolderIterator(ch, deepness='event'):
        for session in obj.getSessionList():
            for slot in session.getSlotList():
                sessionLoc = session.getOwnLocation()
                sessionRoom = session.getOwnRoom()
                if (sessionRoom is not None or sessionLoc is not None) and \
                    (slot.getOwnRoom() is None and slot.getOwnLocation() is None):
                    if sessionLoc:
                        loc = CustomLocation()
                        slot.setLocation(loc)
                        loc.setName(sessionLoc.getName())
                        loc.setAddress(sessionLoc.getAddress())
                    if sessionRoom:
                        r = CustomRoom()
                        slot.setRoom(r)
                        r.setName(sessionRoom.getName())
                        if sessionLoc and withRBDB:
                            r.retrieveFullName(sessionLoc.getName())
        if i%1000 == 999:
            dbi.commit()
        i+=1
    dbi.commit()
Beispiel #2
0
def _assign_room(obj, room, flash_message=True):
    if flash_message:
        flash(_(u"Room of {0} '{1}' set to '{2}'").format(obj.getVerboseType().lower(), obj.getTitle().decode('utf-8'),
                                                          room.full_name), 'info')
    if isinstance(obj, Session):
        for slot in obj.getSlotList():
            _assign_room(slot, room, False)
        return
    custom_location = CustomLocation()
    custom_location.setName(room.location_name)
    custom_room = CustomRoom()
    custom_room.setName(room.name)
    custom_room.setFullName(room.full_name)
    obj.setRoom(custom_room)
    obj.setLocation(custom_location)