Unverified Commit 926c745a by Christopher Lee Committed by GitHub

Merge pull request #16372 from proversity-org/proversity/default-course-mobile-availability

add DEFAULT_MOBILE_AVAILABLE flag
parents d6970826 f38e5ab9
......@@ -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)
......
......@@ -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,
......
......@@ -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(
......
......@@ -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]),
......
......@@ -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,
......
......@@ -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]),
......
......@@ -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}),
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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):
......
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