def course_infos(course): d = { 'course_image_url': course_image_url(course) } for section in ['title', 'university']: d[section] = get_about_section(course, section) return d
def get_about_sections(course_descriptor): about_sections = { field: get_about_section(course_descriptor, field) or '' for field in ABOUT_SECTION_FIELDS } about_sections['effort'] = about_sections['effort'].replace('\n', '') # clean the many CRs if about_sections['video']: try: # edX stores the Youtube iframe HTML code, let's extract the Dailymotion Cloud ID about_sections['video'] = re.findall(r'www.youtube.com/embed/(?P<hash>[\w]+)\?', about_sections['video'])[0] except IndexError: pass return about_sections
def get_about_sections(course_descriptor): about_sections = { field: get_about_section(course_descriptor, field) or '' for field in ABOUT_SECTION_FIELDS } about_sections['effort'] = about_sections['effort'].replace( '\n', '') # clean the many CRs if about_sections['video']: try: # edX stores the Youtube iframe HTML code, let's extract the Dailymotion Cloud ID about_sections['video'] = re.findall( r'www.youtube.com/embed/(?P<hash>[\w]+)\?', about_sections['video'])[0] except IndexError: pass return about_sections
def test_teaser_public_id(self): """ Tests that we always get a correct dailymotion id from the about section. The public video id is store in Mongo surrounded by an iframe tag referencing youtube. As we use dailmotion we need to extract the id from the iframe and create a new one referencing dailymotion (see function get_teaser). """ from contentstore.views.course import settings_handler course = CourseFactory.create() instructor = InstructorFactory.create(course_key=course.id) self.client.login(username=instructor.username, password="******") dm_code = 'x2an9mg' course_details = {'intro_video': dm_code} self.client.post(reverse(settings_handler, args=[str(course.id)]), json.dumps(course_details), content_type='application/json', HTTP_ACCEPT='application/json') video_tag_youtube = get_about_section(course, 'video') self.assertIn(dm_code, video_tag_youtube)
def test_teaser_public_id(self): """ Tests that we always get a correct dailmotion id from the about section. The public video id is store in Mongo surrounded by an iframe tag referencing youtube. As we use dailmotion we need to extract the id from the iframe and create a new one referencing dailymotion (see function get_teaser). """ from contentstore.views.course import settings_handler course = CourseFactory.create() instructor = InstructorFactory.create(course_key=course.id) self.client.login(username=instructor.username, password="******") dm_code = 'x2an9mg' course_details = {'intro_video' : dm_code} self.client.post(reverse(settings_handler, args=[str(course.id)]), json.dumps(course_details), content_type='application/json', HTTP_ACCEPT='application/json') video_tag_youtube = get_about_section(course, 'video') self.assertIn(dm_code, video_tag_youtube) video_tag_dailymotion = '<iframe id="course-teaser" frameborder="0" scrolling="no" allowfullscreen="" src="//www.dailymotion.com/embed/video/' + dm_code + '/?&api=postMessage"></iframe>' self.assertEqual(video_tag_dailymotion, get_teaser(course, video_tag_youtube))
def course_infos(course): d = {'course_image_url': course_image_url(course)} for section in ['title', 'university']: d[section] = get_about_section(course, section) return d