diff --git a/common/test/acceptance/tests/lms/test_lms_dashboard.py b/common/test/acceptance/tests/lms/test_lms_dashboard.py index ea16b2bd38..4788d9e342 100644 --- a/common/test/acceptance/tests/lms/test_lms_dashboard.py +++ b/common/test/acceptance/tests/lms/test_lms_dashboard.py @@ -306,6 +306,39 @@ class LmsDashboardPageTest(BaseLmsDashboardTest): # and course starts within 5 days self.assertEqual(course_date, expected_course_date) + def test_advertised_start_date(self): + + """ + Scenario: + Course Date should be advertised start date + if the course on student dashboard has `Course Advertised Start` set. + + As a Student, + Given that I have enrolled to a course + And the course has `Course Advertised Start` set. + When I visit dashboard page + Then the advertised start date should be displayed rather course start date" + """ + course_start_date = self.now + datetime.timedelta(days=2) + course_advertised_start = "Winter 2018" + + self.course_fixture.add_course_details({ + 'start_date': course_start_date, + }) + self.course_fixture.configure_course() + + self.course_fixture.add_advanced_settings({ + u"advertised_start": {u"value": course_advertised_start} + }) + self.course_fixture._add_advanced_settings() + + expected_course_date = "Starts - {start_date}".format(start_date=course_advertised_start) + + self.dashboard_page.visit() + course_date = self.dashboard_page.get_course_date() + + self.assertEqual(course_date, expected_course_date) + def test_profile_img_alt_empty(self): """ Validate value of profile image alt attribue is null diff --git a/lms/templates/dashboard/_dashboard_course_listing.html b/lms/templates/dashboard/_dashboard_course_listing.html index 96b3cd9d4f..7458b2f3f5 100644 --- a/lms/templates/dashboard/_dashboard_course_listing.html +++ b/lms/templates/dashboard/_dashboard_course_listing.html @@ -110,19 +110,19 @@ from util.course import get_link_for_about_page course_date = course_overview.end elif course_overview.has_started(): container_string = _("Started - {date}") - course_date = course_overview.start + course_date = course_overview.dashboard_start_display elif course_overview.starts_within(days=5): container_string = _("Starts - {date}") - course_date = course_overview.start + course_date = course_overview.dashboard_start_display format = 'defaultFormat' else: ## hasn't started yet container_string = _("Starts - {date}") - course_date = course_overview.start + course_date = course_overview.dashboard_start_display endif endif %> - % if isinstance(course_date, str): + % if isinstance(course_date, basestring): ${_(container_string).format(date=course_date)} % elif course_date is not None: <% diff --git a/openedx/core/djangoapps/content/course_overviews/models.py b/openedx/core/djangoapps/content/course_overviews/models.py index e8eeac4008..2b8b22bb21 100644 --- a/openedx/core/djangoapps/content/course_overviews/models.py +++ b/openedx/core/djangoapps/content/course_overviews/models.py @@ -361,6 +361,13 @@ class CourseOverview(TimeStampedModel): """ return block_metadata_utils.display_name_with_default_escaped(self) + @property + def dashboard_start_display(self): + """ + Return start date to diplay on learner's dashboard, preferably `Course Advertised Start` + """ + return self.advertised_start or self.start + def has_started(self): """ Returns whether the the course has started.