Example #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)
Example #2
0
def _set_room_capability():
    for room in Room.all_rooms():
        if room.location in ['Barrows 106', 'Barker 101']:
            Room.update_capability(room.id, 'screencast')
        elif room.location in ['Li Ka Shing 145']:
            Room.set_auditorium(room.id, True)
            Room.update_capability(room.id, 'screencast_and_video')
    std_commit(allow_test_environment=True)
Example #3
0
 def test_get_room(self, client, admin_session):
     """Admin user has access to room data."""
     location = 'Barrows 106'
     room = next((r for r in Room.all_rooms() if r.location == location),
                 None)
     assert room
     api_json = self._api_room(client, room.id)
     assert api_json['id'] == room.id
     assert api_json['isAuditorium'] is False
     assert api_json['location'] == location
     assert api_json['kalturaResourceId'] == 890
     assert len(api_json['recordingTypeOptions']) == 1
Example #4
0
 def test_get_auditorium(self, client, admin_session):
     """Admin user has access to auditorium metadata."""
     location = 'Li Ka Shing 145'
     room = next((r for r in Room.all_rooms() if r.location == location),
                 None)
     assert room
     api_json = self._api_room(client, room.id)
     assert api_json['id'] == room.id
     assert api_json['isAuditorium'] is True
     assert api_json['kalturaResourceId'] == 678
     assert api_json['location'] == location
     assert len(api_json['recordingTypeOptions']) == 3
     # Feed includes courses but room-per-course would be redundant
     assert len(api_json['courses']) > 0
     assert 'room' not in api_json['courses'][0]
Example #5
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)

    rooms = Room.all_rooms()
    kaltura_resource_ids_per_room = {}
    for resource in Kaltura().get_resource_list():
        room = next((r for r in rooms if r.location == resource['name']), None)
        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)
Example #6
0
    def test_get_room(self, client, admin_session):
        """Admin user has access to room data."""
        location = "O'Brien 212"
        room = next((r for r in Room.all_rooms() if r.location == location),
                    None)
        assert room
        api_json = self._api_room(client, room.id)
        assert api_json['id'] == room.id
        assert api_json['isAuditorium'] is True
        assert api_json['location'] == location
        assert api_json['kalturaResourceId'] == 890
        assert len(api_json['recordingTypeOptions']) == 1

        # Simple verification of courses sort order
        courses = api_json['courses']
        assert len(courses) > 1

        def _days_first_eligible(course):
            return course['meetings']['eligible'][0]['daysFormatted'][0]

        for index in range(1, len(courses)):
            assert _days_first_eligible(
                courses[index - 1]) <= _days_first_eligible(courses[index])
Example #7
0
def get_all_rooms():
    return tolerant_jsonify([room.to_api_json() for room in Room.all_rooms()])