diff --git a/cms/envs/aws.py b/cms/envs/aws.py index 999a05c026..ddde708396 100644 --- a/cms/envs/aws.py +++ b/cms/envs/aws.py @@ -107,6 +107,12 @@ if STATIC_URL_BASE: # DEFAULT_COURSE_ABOUT_IMAGE_URL specifies the default image to show for courses that don't provide one DEFAULT_COURSE_ABOUT_IMAGE_URL = ENV_TOKENS.get('DEFAULT_COURSE_ABOUT_IMAGE_URL', DEFAULT_COURSE_ABOUT_IMAGE_URL) +# DEFAULT_MOBILE_AVAILABLE specifies if the course is available for mobile by default +DEFAULT_MOBILE_AVAILABLE = ENV_TOKENS.get( + 'DEFAULT_MOBILE_AVAILABLE', + DEFAULT_MOBILE_AVAILABLE +) + # MEDIA_ROOT specifies the directory where user-uploaded files are stored. MEDIA_ROOT = ENV_TOKENS.get('MEDIA_ROOT', MEDIA_ROOT) MEDIA_URL = ENV_TOKENS.get('MEDIA_URL', MEDIA_URL) diff --git a/cms/envs/common.py b/cms/envs/common.py index f1572e34d0..d6e60b2330 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -109,6 +109,8 @@ from lms.envs.common import ( PASSWORD_RESET_SUPPORT_LINK, ACTIVATION_EMAIL_SUPPORT_LINK, + DEFAULT_MOBILE_AVAILABLE, + CONTACT_EMAIL, DISABLE_ACCOUNT_ACTIVATION_REQUIREMENT_SWITCH, diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 802f8f695d..a491796280 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -7,6 +7,8 @@ from cStringIO import StringIO from datetime import datetime, timedelta import dateutil.parser +from django.conf import settings + import requests from lazy import lazy from lxml import etree @@ -32,6 +34,8 @@ CATALOG_VISIBILITY_CATALOG_AND_ABOUT = "both" CATALOG_VISIBILITY_ABOUT = "about" CATALOG_VISIBILITY_NONE = "none" +DEFAULT_MOBILE_AVAILABLE = getattr(settings, 'DEFAULT_MOBILE_AVAILABLE', False) + class StringOrDate(Date): def from_json(self, value): @@ -337,7 +341,7 @@ class CourseFields(object): mobile_available = Boolean( display_name=_("Mobile Course Available"), help=_("Enter true or false. If true, the course will be available to mobile devices."), - default=False, + default=DEFAULT_MOBILE_AVAILABLE, scope=Scope.settings ) video_upload_pipeline = Dict( diff --git a/lms/djangoapps/course_api/tests/test_api.py b/lms/djangoapps/course_api/tests/test_api.py index 0885611353..4eb3c5d2f4 100644 --- a/lms/djangoapps/course_api/tests/test_api.py +++ b/lms/djangoapps/course_api/tests/test_api.py @@ -158,7 +158,7 @@ class TestGetCourseListMultipleCourses(CourseListTestMixin, ModuleStoreTestCase) def setUp(self): super(TestGetCourseListMultipleCourses, self).setUp() - self.course = self.create_course() + self.course = self.create_course(mobile_available=False) self.staff_user = self.create_user("staff", is_staff=True) self.honor_user = self.create_user("honor", is_staff=False) @@ -191,7 +191,7 @@ class TestGetCourseListMultipleCourses(CourseListTestMixin, ModuleStoreTestCase) def test_filter(self): # Create a second course to be filtered out of queries. - alternate_course = self.create_course(course='mobile', mobile_available=True) + alternate_course = self.create_course(course='mobile') test_cases = [ (None, [alternate_course, self.course]), diff --git a/lms/djangoapps/course_api/tests/test_serializers.py b/lms/djangoapps/course_api/tests/test_serializers.py index 3d685f1817..179df69e9b 100644 --- a/lms/djangoapps/course_api/tests/test_serializers.py +++ b/lms/djangoapps/course_api/tests/test_serializers.py @@ -70,7 +70,7 @@ class TestCourseSerializer(CourseApiFactoryMixin, ModuleStoreTestCase): 'blocks_url': u'http://testserver/api/courses/v1/blocks/?course_id=edX%2Ftoy%2F2012_Fall', 'effort': u'6 hours', 'pacing': 'instructor', - 'mobile_available': False, + 'mobile_available': True, 'hidden': False, 'invitation_only': False, diff --git a/lms/djangoapps/course_api/tests/test_views.py b/lms/djangoapps/course_api/tests/test_views.py index f2987b8496..199d300848 100644 --- a/lms/djangoapps/course_api/tests/test_views.py +++ b/lms/djangoapps/course_api/tests/test_views.py @@ -106,7 +106,7 @@ class CourseListViewTestCaseMultipleCourses(CourseApiTestViewMixin, ModuleStoreT def setUp(self): super(CourseListViewTestCaseMultipleCourses, self).setUp() - self.course = self.create_course() + self.course = self.create_course(mobile_available=False) self.url = reverse('course-list') self.staff_user = self.create_user(username='staff', is_staff=True) self.honor_user = self.create_user(username='honor', is_staff=False) @@ -139,7 +139,7 @@ class CourseListViewTestCaseMultipleCourses(CourseApiTestViewMixin, ModuleStoreT self.setup_user(self.staff_user) # Create a second course to be filtered out of queries. - alternate_course = self.create_course(course='mobile', mobile_available=True) + alternate_course = self.create_course(course='mobile') test_cases = [ (None, [alternate_course, self.course]), diff --git a/lms/djangoapps/courseware/tests/test_courses.py b/lms/djangoapps/courseware/tests/test_courses.py index 50c6f137ed..ef277557b8 100644 --- a/lms/djangoapps/courseware/tests/test_courses.py +++ b/lms/djangoapps/courseware/tests/test_courses.py @@ -150,8 +150,9 @@ class CoursesTest(ModuleStoreTestCase): Verify that filtering performs as expected. """ user = UserFactory.create() - non_mobile_course = CourseFactory.create(emit_signals=True) - mobile_course = CourseFactory.create(mobile_available=True, emit_signals=True) + mobile_course = CourseFactory.create(emit_signals=True) + non_mobile_course =\ + CourseFactory.create(mobile_available=False, emit_signals=True) test_cases = ( (None, {non_mobile_course.id, mobile_course.id}), diff --git a/lms/envs/aws.py b/lms/envs/aws.py index 92698d7355..fa373d74af 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -761,6 +761,11 @@ COURSE_ABOUT_VISIBILITY_PERMISSION = ENV_TOKENS.get( COURSE_ABOUT_VISIBILITY_PERMISSION ) +DEFAULT_MOBILE_AVAILABLE = ENV_TOKENS.get( + 'DEFAULT_MOBILE_AVAILABLE', + DEFAULT_MOBILE_AVAILABLE +) + # Enrollment API Cache Timeout ENROLLMENT_COURSE_DETAILS_CACHE_TIMEOUT = ENV_TOKENS.get('ENROLLMENT_COURSE_DETAILS_CACHE_TIMEOUT', 60) diff --git a/lms/envs/common.py b/lms/envs/common.py index 68675917db..8654488b29 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -2966,6 +2966,7 @@ COURSE_CATALOG_VISIBILITY_PERMISSION = 'see_exists' # visible. We default this to the legacy permission 'see_exists'. COURSE_ABOUT_VISIBILITY_PERMISSION = 'see_exists' +DEFAULT_MOBILE_AVAILABLE = True # Enrollment API Cache Timeout ENROLLMENT_COURSE_DETAILS_CACHE_TIMEOUT = 60 diff --git a/lms/envs/test.py b/lms/envs/test.py index 4a0d1968bb..d2db7bf33b 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -83,6 +83,8 @@ FEATURES['ENABLE_ENROLLMENT_TRACK_USER_PARTITION'] = True FEATURES['ENABLE_BULK_ENROLLMENT_VIEW'] = True +DEFAULT_MOBILE_AVAILABLE = True + # Need wiki for courseware views to work. TODO (vshnayder): shouldn't need it. WIKI_ENABLED = True diff --git a/openedx/core/djangoapps/content/course_overviews/tests/test_course_overviews.py b/openedx/core/djangoapps/content/course_overviews/tests/test_course_overviews.py index 197493a149..56e61a234c 100644 --- a/openedx/core/djangoapps/content/course_overviews/tests/test_course_overviews.py +++ b/openedx/core/djangoapps/content/course_overviews/tests/test_course_overviews.py @@ -478,8 +478,9 @@ class CourseOverviewTestCase(CatalogIntegrationMixin, ModuleStoreTestCase): ) def test_get_all_courses_by_mobile_available(self): - non_mobile_course = CourseFactory.create(emit_signals=True) - mobile_course = CourseFactory.create(mobile_available=True, emit_signals=True) + mobile_course = CourseFactory.create(emit_signals=True) + non_mobile_course =\ + CourseFactory.create(mobile_available=False, emit_signals=True) test_cases = ( (None, {non_mobile_course.id, mobile_course.id}), @@ -495,7 +496,8 @@ class CourseOverviewTestCase(CatalogIntegrationMixin, ModuleStoreTestCase): CourseOverview.get_all_courses(filter_=filter_) }, expected_courses, - "testing CourseOverview.get_all_courses with filter_={}".format(filter_), + "testing CourseOverview.get_all_courses with filter_={}" + .format(filter_), ) def test_get_from_ids_if_exists(self):