-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Handle taking registrations on a course with TBD start date #2307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -821,6 +821,10 @@ def id(self): | |
|
|
||
| @property | ||
| 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): | ||
| try: | ||
| result = Date().from_json(text) | ||
|
|
@@ -835,12 +839,22 @@ def try_parse_iso_8601(text): | |
|
|
||
| if isinstance(self.advertised_start, basestring): | ||
| return try_parse_iso_8601(self.advertised_start) | ||
| elif self.advertised_start is None and self.start is None: | ||
| # TODO this is an impossible state since the init function forces start to have a value | ||
| return 'TBD' | ||
| elif self.start_date_is_still_default: | ||
| _ = self.runtime.service(self, "i18n").ugettext | ||
| # Translators: TBD stands for 'To Be Determined' and is used when a course | ||
| # does not yet have an announced start date. | ||
| return _('TBD') | ||
| else: | ||
| return (self.advertised_start or self.start).strftime("%b %d, %Y") | ||
|
|
||
| @property | ||
| def start_date_is_still_default(self): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this method name is splendidly descriptive, but pylint still requires a docstring. 844: C0111: (missing-docstring), CourseDescriptor.start_date_is_still_default: Missing docstring |
||
| """ | ||
| 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 16 years from now, are we going to wonder why a course whose author set the start date to January 1st isn't showing up? ;) |
||
|
|
||
| @property | ||
| def end_date_text(self): | ||
| """ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,23 +134,29 @@ def test_sorting_score(self, gmtime_mock): | |
| print "Comparing %s to %s" % (a, b) | ||
| 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') | ||
| def test_start_date_text(self, gmtime_mock): | ||
| gmtime_mock.return_value = NOW | ||
|
|
||
| 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: | ||
| for s in self.start_advertised_settings: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is not actually being run (see diff cover report) because you copied the test method name for your new test point below. When I changed the test name, I got a failure for this older test point.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah. nice catch, i'll fix. |
||
| d = get_dummy_course(start=s[0], advertised_start=s[1]) | ||
| print "Checking start=%s advertised=%s" % (s[0], s[1]) | ||
| 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): | ||
| descriptor = get_dummy_course(start='2012-12-02T12:00', is_new=True) | ||
| self.assertNotEqual(descriptor.location.org, descriptor.display_org_with_default) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,9 @@ <h2><span class="course-number">${course.display_number_with_default | h}</span> | |
| </div> | ||
| <div class="bottom"> | ||
| <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> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit pick-- there is a divider shown between the university and the start date on the "courses" listing. This looks odd when there is no date to display. |
||
| % endif | ||
| </div> | ||
| </section> | ||
| </div> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no mention here of "TBD" - where would that get displayed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually,
course.start_date_is_still_defaultis used everywhere to prevent the literal string"TBD"from being displayed anywhere. So it was "preemptive" internationalization more than anything else.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah OK, thanks for clarifying.