diff --git a/cms/djangoapps/models/settings/course_details.py b/cms/djangoapps/models/settings/course_details.py index 28dba473f2..07eb4bc309 100644 --- a/cms/djangoapps/models/settings/course_details.py +++ b/cms/djangoapps/models/settings/course_details.py @@ -73,9 +73,9 @@ class CourseDetails(object): """ Decode the json into CourseDetails and save any changed attrs to the db """ - # # TODO make it an error for this to be undefined & for it to not be retrievable from modulestore + # TODO make it an error for this to be undefined & for it to not be retrievable from modulestore course_location = jsondict['course_location'] - # # Will probably want to cache the inflight courses because every blur generates an update + # Will probably want to cache the inflight courses because every blur generates an update descriptor = get_modulestore(course_location).get_item(course_location) dirty = False diff --git a/common/lib/xmodule/xmodule/tests/test_date_utils.py b/common/lib/xmodule/xmodule/tests/test_date_utils.py new file mode 100644 index 0000000000..a7e2549865 --- /dev/null +++ b/common/lib/xmodule/xmodule/tests/test_date_utils.py @@ -0,0 +1,20 @@ +# Tests for xmodule.util.date_utils + +from nose.tools import assert_equals +from xmodule.util import date_utils +import datetime +from pytz import UTC + + +def test_get_default_time_display(): + assert_equals("", date_utils.get_default_time_display(None)) + test_time = datetime.datetime(1992, 3, 12, 15, 3, 30, tzinfo=UTC) + assert_equals( + "Mar 12, 1992 at 15:03 UTC", + date_utils.get_default_time_display(test_time)) + assert_equals( + "Mar 12, 1992 at 15:03 UTC", + date_utils.get_default_time_display(test_time, True)) + assert_equals( + "Mar 12, 1992 at 15:03", + date_utils.get_default_time_display(test_time, False)) diff --git a/common/lib/xmodule/xmodule/util/date_utils.py b/common/lib/xmodule/xmodule/util/date_utils.py index e128d6eab7..2db87be47b 100644 --- a/common/lib/xmodule/xmodule/util/date_utils.py +++ b/common/lib/xmodule/xmodule/util/date_utils.py @@ -8,6 +8,8 @@ def get_default_time_display(dt, show_timezone=True): If None is passed in for dt, an empty string will be returned. The default value of show_timezone is True. """ + if dt is None: + return "" timezone = "" if dt is not None and show_timezone: if dt.tzinfo is not None: