Exemplo n.º 1
0
def refresh_rooms():
    locations = SisSection.get_distinct_meeting_locations()
    existing_locations = Room.get_all_locations()
    new_locations = [
        location for location in locations
        if location not in existing_locations
    ]
    if new_locations:
        app.logger.info(f'Creating {len(new_locations)} new rooms')
        for location in new_locations:
            Room.create(location=location)

    def _normalize(room_location):
        return re.sub(r'[\W_]+', '', room_location).lower()

    kaltura_resource_ids_per_room = {}
    all_rooms = Room.all_rooms()
    for resource in Kaltura().get_schedule_resources():
        location = _normalize(resource['name'])
        if location:
            for room in all_rooms:
                if _normalize(room.location) == location:
                    kaltura_resource_ids_per_room[room.id] = resource['id']
                    break

    if kaltura_resource_ids_per_room:
        Room.update_kaltura_resource_mappings(kaltura_resource_ids_per_room)
Exemplo n.º 2
0
def refresh_rooms():
    locations = SisSection.get_distinct_meeting_locations()
    existing_locations = Room.get_all_locations()
    new_locations = [
        location for location in locations
        if location not in existing_locations
    ]
    if new_locations:
        app.logger.info(f'Creating {len(new_locations)} new rooms')
        for location in new_locations:
            Room.create(location=location)

    kaltura_resource_ids_per_room = {}
    for resource in Kaltura().get_schedule_resources():
        room = Room.find_room(location=resource['name'])
        if room:
            kaltura_resource_ids_per_room[room.id] = resource['id']

    if kaltura_resource_ids_per_room:
        Room.update_kaltura_resource_mappings(kaltura_resource_ids_per_room)