Commit 7ac13bf8 by Jason Bau

Don't show course start date if it hasn't been set.

If neither start nor advertised_start has been changed from default
don't show the course start date.

This allows us to accept course registrations for courses whose start
date is yet TBD.
parent 27b2ff7e
...@@ -5,6 +5,10 @@ These are notable changes in edx-platform. This is a rolling list of changes, ...@@ -5,6 +5,10 @@ These are notable changes in edx-platform. This is a rolling list of changes,
in roughly chronological order, most recent first. Add your entries at or near in roughly chronological order, most recent first. Add your entries at or near
the top. Include a label indicating the component affected. the top. Include a label indicating the component affected.
LMS: If the course start date is kept at the default studio value (Jan 1, 2030)
and advertised_start is not set, the start date is not displayed in the
/courses tile view, the course about page, or the dashboard
Blades: Add role parameter to LTI. BLD-583. Blades: Add role parameter to LTI. BLD-583.
Blades: Bugfix "In Firefox YouTube video with start time plays from 00:00:00". Blades: Bugfix "In Firefox YouTube video with start time plays from 00:00:00".
......
...@@ -821,6 +821,10 @@ class CourseDescriptor(CourseFields, SequenceDescriptor): ...@@ -821,6 +821,10 @@ class CourseDescriptor(CourseFields, SequenceDescriptor):
@property @property
def start_date_text(self): def start_date_text(self):
"""
Returns the desired text corresponding the course's start date. Prefers .advertised_start,
then falls back to .start
"""
def try_parse_iso_8601(text): def try_parse_iso_8601(text):
try: try:
result = Date().from_json(text) result = Date().from_json(text)
...@@ -835,13 +839,23 @@ class CourseDescriptor(CourseFields, SequenceDescriptor): ...@@ -835,13 +839,23 @@ class CourseDescriptor(CourseFields, SequenceDescriptor):
if isinstance(self.advertised_start, basestring): if isinstance(self.advertised_start, basestring):
return try_parse_iso_8601(self.advertised_start) return try_parse_iso_8601(self.advertised_start)
elif self.advertised_start is None and self.start is None: elif self.start_date_is_still_default:
# TODO this is an impossible state since the init function forces start to have a value _ = self.runtime.service(self, "i18n").ugettext
return 'TBD' # Translators: TBD stands for 'To Be Determined' and is used when a course
# does not yet have an announced start date.
return _('TBD')
else: else:
return (self.advertised_start or self.start).strftime("%b %d, %Y") return (self.advertised_start or self.start).strftime("%b %d, %Y")
@property @property
def start_date_is_still_default(self):
"""
Checks if the start date set for the course is still default, i.e. .start has not been modified,
and .advertised_start has not been set.
"""
return self.advertised_start is None and self.start == CourseFields.start.default
@property
def end_date_text(self): def end_date_text(self):
""" """
Returns the end date for the course formatted as a string. Returns the end date for the course formatted as a string.
......
...@@ -134,23 +134,29 @@ class IsNewCourseTestCase(unittest.TestCase): ...@@ -134,23 +134,29 @@ class IsNewCourseTestCase(unittest.TestCase):
print "Comparing %s to %s" % (a, b) print "Comparing %s to %s" % (a, b)
assertion(a_score, b_score) assertion(a_score, b_score)
start_advertised_settings = [
# start, advertised, result, is_still_default
('2012-12-02T12:00', None, 'Dec 02, 2012', False),
('2012-12-02T12:00', '2011-11-01T12:00', 'Nov 01, 2011', False),
('2012-12-02T12:00', 'Spring 2012', 'Spring 2012', False),
('2012-12-02T12:00', 'November, 2011', 'November, 2011', False),
(xmodule.course_module.CourseFields.start.default, None, 'TBD', True),
(xmodule.course_module.CourseFields.start.default, 'January 2014', 'January 2014', False),
]
@patch('xmodule.course_module.datetime.now') @patch('xmodule.course_module.datetime.now')
def test_start_date_text(self, gmtime_mock): def test_start_date_text(self, gmtime_mock):
gmtime_mock.return_value = NOW gmtime_mock.return_value = NOW
for s in self.start_advertised_settings:
settings = [
# start, advertized, result
('2012-12-02T12:00', None, 'Dec 02, 2012'),
('2012-12-02T12:00', '2011-11-01T12:00', 'Nov 01, 2011'),
('2012-12-02T12:00', 'Spring 2012', 'Spring 2012'),
('2012-12-02T12:00', 'November, 2011', 'November, 2011'),
]
for s in settings:
d = get_dummy_course(start=s[0], advertised_start=s[1]) d = get_dummy_course(start=s[0], advertised_start=s[1])
print "Checking start=%s advertised=%s" % (s[0], s[1]) print "Checking start=%s advertised=%s" % (s[0], s[1])
self.assertEqual(d.start_date_text, s[2]) self.assertEqual(d.start_date_text, s[2])
def test_start_date_is_default(self):
for s in self.start_advertised_settings:
d = get_dummy_course(start=s[0], advertised_start=s[1])
self.assertEqual(d.start_date_is_still_default, s[3])
def test_display_organization(self): def test_display_organization(self):
descriptor = get_dummy_course(start='2012-12-02T12:00', is_new=True) descriptor = get_dummy_course(start='2012-12-02T12:00', is_new=True)
self.assertNotEqual(descriptor.location.org, descriptor.display_org_with_default) self.assertNotEqual(descriptor.location.org, descriptor.display_org_with_default)
......
...@@ -226,14 +226,14 @@ ...@@ -226,14 +226,14 @@
width: 100%; width: 100%;
.university { .university {
border-right: 1px solid $border-color-2;
color: $lighter-base-font-color; color: $lighter-base-font-color;
letter-spacing: 1px; letter-spacing: 1px;
margin-right: 10px;
padding-right: 10px;
} }
.start-date { .start-date {
border-left: 1px solid $border-color-2;
margin-left: 5px;
padding-left: 10px;
color: $lighter-base-font-color; color: $lighter-base-font-color;
letter-spacing: 1px; letter-spacing: 1px;
} }
......
...@@ -26,7 +26,9 @@ from courseware.courses import course_image_url, get_course_about_section ...@@ -26,7 +26,9 @@ from courseware.courses import course_image_url, get_course_about_section
</div> </div>
<div class="bottom"> <div class="bottom">
<span class="university">${get_course_about_section(course, 'university')}</span> <span class="university">${get_course_about_section(course, 'university')}</span>
% if not course.start_date_is_still_default:
<span class="start-date">${course.start_date_text}</span> <span class="start-date">${course.start_date_text}</span>
% endif
</div> </div>
</section> </section>
</div> </div>
......
...@@ -248,8 +248,9 @@ ...@@ -248,8 +248,9 @@
<ol class="important-dates"> <ol class="important-dates">
<li><div class="icon course-number"></div><p>${_("Course Number")}</p><span class="course-number">${course.display_number_with_default | h}</span></li> <li><div class="icon course-number"></div><p>${_("Course Number")}</p><span class="course-number">${course.display_number_with_default | h}</span></li>
% if not course.start_date_is_still_default:
<li><div class="icon start"></div><p>${_("Classes Start")}</p><span class="start-date">${course.start_date_text}</span></li> <li><div class="icon start"></div><p>${_("Classes Start")}</p><span class="start-date">${course.start_date_text}</span></li>
% endif
## We plan to ditch end_date (which is not stored in course metadata), ## We plan to ditch end_date (which is not stored in course metadata),
## but for backwards compatibility, show about/end_date blob if it exists. ## but for backwards compatibility, show about/end_date blob if it exists.
% if get_course_about_section(course, "end_date") or course.end: % if get_course_about_section(course, "end_date") or course.end:
......
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
${_("Course Completed - {end_date}").format(end_date=course.end_date_text)} ${_("Course Completed - {end_date}").format(end_date=course.end_date_text)}
% elif course.has_started(): % elif course.has_started():
${_("Course Started - {start_date}").format(start_date=course.start_date_text)} ${_("Course Started - {start_date}").format(start_date=course.start_date_text)}
% elif course.start_date_is_still_default: # Course start date TBD
${_("Course has not yet started")}
% else: # hasn't started yet % else: # hasn't started yet
${_("Course Starts - {start_date}").format(start_date=course.start_date_text)} ${_("Course Starts - {start_date}").format(start_date=course.start_date_text)}
% endif % endif
......
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