Commit 9d88bef1 by Peter Fogg

Allow setting `self_paced` through course details endpoint.

ECOM-2489
parent 15d77fda
......@@ -56,6 +56,7 @@ class CourseDetailsTestCase(CourseTestCase):
self.assertIsNone(details.effort, "effort somehow initialized" + str(details.effort))
self.assertIsNone(details.language, "language somehow initialized" + str(details.language))
self.assertIsNone(details.has_cert_config)
self.assertFalse(details.self_paced)
def test_encoder(self):
details = CourseDetails.fetch(self.course.id)
......@@ -128,6 +129,11 @@ class CourseDetailsTestCase(CourseTestCase):
CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).language,
jsondetails.language
)
jsondetails.self_paced = True
self.assertEqual(
CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).self_paced,
jsondetails.self_paced
)
@override_settings(MKTG_URLS={'ROOT': 'dummy-root'})
def test_marketing_site_fetch(self):
......@@ -334,6 +340,7 @@ class CourseDetailsViewTest(CourseTestCase):
self.alter_field(url, details, 'effort', "effort")
self.alter_field(url, details, 'course_image_name', "course_image_name")
self.alter_field(url, details, 'language', "en")
self.alter_field(url, details, 'self_paced', "true")
def compare_details_with_encoding(self, encoded, details, context):
"""
......
......@@ -54,6 +54,7 @@ class CourseDetails(object):
'50'
) # minimum passing score for entrance exam content module/tree,
self.has_cert_config = None # course has active certificate configuration
self.self_paced = None
@classmethod
def _fetch_about_attribute(cls, course_key, attribute):
......@@ -86,6 +87,7 @@ class CourseDetails(object):
# Default course license is "All Rights Reserved"
course_details.license = getattr(descriptor, "license", "all-rights-reserved")
course_details.has_cert_config = has_active_web_certificate(descriptor)
course_details.self_paced = descriptor.self_paced
for attribute in ABOUT_ATTRIBUTES:
value = cls._fetch_about_attribute(course_key, attribute)
......@@ -188,6 +190,10 @@ class CourseDetails(object):
descriptor.language = jsondict['language']
dirty = True
if 'self_paced' in jsondict and jsondict['self_paced'] != descriptor.self_paced:
descriptor.self_paced = jsondict['self_paced']
dirty = True
if dirty:
module_store.update_item(descriptor, user.id)
......
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