Commit e77bcab5 by Nimisha Asthagiri

MA-345 Mobile Enrollment API: add course' Facebook URL

parent 4e454cca
......@@ -64,6 +64,10 @@ class CourseMetadata(object):
if not settings.FEATURES.get('ENABLE_VIDEO_UPLOAD_PIPELINE'):
filtered_list.append('video_upload_pipeline')
# Do not show facebook_url if the feature is disabled.
if not settings.FEATURES.get('ENABLE_MOBILE_SOCIAL_FACEBOOK_FEATURES'):
filtered_list.append('facebook_url')
return filtered_list
@classmethod
......
......@@ -335,6 +335,15 @@ class CourseFields(object):
help=_("Enter the unique identifier for your course's video files provided by edX."),
scope=Scope.settings
)
facebook_url = String(
help=_(
"Enter the URL for the official course Facebook group. "
"If you provide a URL, the mobile app includes a button that students can tap to access the group."
),
default=None,
display_name=_("Facebook URL"),
scope=Scope.settings
)
no_grade = Boolean(
display_name=_("Course Not Graded"),
help=_("Enter true or false. If true, the course will not be graded."),
......
......@@ -50,6 +50,9 @@ class CourseField(serializers.RelatedField):
"start": course.start,
"end": course.end,
"course_image": course_image_url(course),
"social_urls": {
"facebook": course.facebook_url,
},
"latest_updates": {
"video": None
},
......
......@@ -5,7 +5,6 @@ import datetime
from django.utils import timezone
from xmodule.modulestore.tests.factories import ItemFactory, CourseFactory
from xmodule.modulestore.django import modulestore
from student.models import CourseEnrollment
from certificates.models import CertificateStatuses
from certificates.tests.factories import GeneratedCertificateFactory
......@@ -107,6 +106,23 @@ class TestUserEnrollmentApi(MobileAPITestCase, MobileAuthUserTestMixin, MobileEn
certificate_data = response.data[0]['certificate'] # pylint: disable=no-member
self.assertEquals(certificate_data['url'], certificate_url)
def test_no_facebook_url(self):
self.login_and_enroll()
response = self.api_response()
course_data = response.data[0]['course'] # pylint: disable=no-member
self.assertIsNone(course_data['social_urls']['facebook'])
def test_facebook_url(self):
self.login_and_enroll()
self.course.facebook_url = "http://facebook.com/test_group_page"
self.store.update_item(self.course, self.user.id)
response = self.api_response()
course_data = response.data[0]['course'] # pylint: disable=no-member
self.assertEquals(course_data['social_urls']['facebook'], self.course.facebook_url)
class CourseStatusAPITestCase(MobileAPITestCase):
"""
......@@ -280,7 +296,7 @@ class TestCourseEnrollmentSerializer(MobileAPITestCase):
self.course.display_coursenumber = "overridden_number"
self.course.display_organization = "overridden_org"
modulestore().update_item(self.course, self.user.id)
self.store.update_item(self.course, self.user.id)
serialized = CourseEnrollmentSerializer(CourseEnrollment.enrollments_for_user(self.user)[0]).data # pylint: disable=no-member
self.assertEqual(serialized['course']['number'], self.course.display_coursenumber)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment