def meeting_start_email(block_id, user_email): """ Send mail to specific user at meeting start """ platform_name = configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME) usage_key = UsageKey.from_string(block_id) course = get_course_by_id(usage_key.course_key) subject = 'Ha comenzado una sesión de Zoom en el curso: {}'.format( course.display_name_with_default) redirect_url = get_lms_link_for_item(usage_key) context = { "course_name": course.display_name_with_default, "platform_name": platform_name, "redirect_url": redirect_url } html_message = render_to_string('emails/meeting_start.txt', context) plain_message = strip_tags(html_message) from_email = configuration_helpers.get_value( 'email_from_address', settings.BULK_EMAIL_DEFAULT_FROM_EMAIL) mail = send_mail(subject, plain_message, from_email, [user_email], fail_silently=False, html_message=html_message) return mail
def lms_link_test(self): """ Tests get_lms_link_for_item. """ course_key = CourseLocator('mitX', '101', 'test') location = course_key.make_usage_key('vertical', 'contacting_us') link = utils.get_lms_link_for_item(location, False) self.assertEqual(link, "//localhost:8000/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type" "@vertical+block@contacting_us") # test preview link = utils.get_lms_link_for_item(location, True) self.assertEqual( link, "//preview.localhost/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type@vertical+block" "@contacting_us " ) # now test with the course' location location = course_key.make_usage_key('course', 'test') link = utils.get_lms_link_for_item(location) self.assertEqual(link, "//localhost:8000/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type" "@course+block@test")