def _update_already_scheduled_events(): kaltura = Kaltura() for course in SisSection.get_courses_scheduled( term_id=app.config['CURRENT_TERM_ID']): course_name = course['label'] scheduled = course['scheduled'] kaltura_schedule = kaltura.get_event( event_id=scheduled['kalturaScheduleId']) if kaltura_schedule: if course['canvasCourseSites'] and scheduled[ 'publishType'] == 'kaltura_media_gallery': # From Kaltura, get Canvas course sites (categories) currently mapped to the course. template_entry_id = kaltura_schedule['templateEntryId'] categories = kaltura.get_categories(template_entry_id) for s in course['canvasCourseSites']: canvas_course_site_id = str(s['courseSiteId']) if canvas_course_site_id not in [ c['name'] for c in categories ]: _update_kaltura_category(canvas_course_site_id, course_name, kaltura, template_entry_id) else: app.logger.warn( f'The previously scheduled {course_name} has no schedule_event in Kaltura.' )
def find_courses(): params = request.get_json() term_id = params.get('termId') filter_ = params.get('filter', 'Not Invited') if filter_ not in get_search_filter_options() or not term_id: raise BadRequestError('One or more required params are missing or invalid') if filter_ == 'Do Not Email': courses = SisSection.get_courses_opted_out(term_id) elif filter_ == 'Invited': courses = SisSection.get_courses_invited(term_id) elif filter_ == 'Not Invited': courses = SisSection.get_eligible_courses_not_invited(term_id) elif filter_ == 'Partially Approved': courses = SisSection.get_courses_partially_approved(term_id) elif filter_ == 'Scheduled': courses = SisSection.get_courses_scheduled(term_id) else: raise BadRequestError(f'Invalid filter: {filter_}') return tolerant_jsonify(courses)