AA-4: Adding waffle flag for dates widget
This commit is contained in:
@@ -49,7 +49,7 @@ from openedx.core.djangoapps.enrollments.api import get_course_enrollment_detail
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
from openedx.core.lib.api.view_utils import LazySequence
|
||||
from openedx.features.course_duration_limits.access import AuditExpiredError
|
||||
from openedx.features.course_experience import COURSE_ENABLE_UNENROLLED_ACCESS_FLAG
|
||||
from openedx.features.course_experience import COURSE_ENABLE_UNENROLLED_ACCESS_FLAG, DATE_WIDGET_V2_FLAG
|
||||
from static_replace import replace_static_urls
|
||||
from student.models import CourseEnrollment
|
||||
from survey.utils import is_survey_required_and_unanswered
|
||||
@@ -401,7 +401,6 @@ def get_course_date_blocks(course, user, request=None, include_past_dates=False,
|
||||
"""
|
||||
block_classes = [
|
||||
CourseEndDate,
|
||||
CourseExpiredDate,
|
||||
CourseStartDate,
|
||||
TodaysDate,
|
||||
VerificationDeadlineDate,
|
||||
@@ -411,8 +410,10 @@ def get_course_date_blocks(course, user, request=None, include_past_dates=False,
|
||||
block_classes.insert(0, CertificateAvailableDate)
|
||||
|
||||
blocks = [cls(course, user) for cls in block_classes]
|
||||
blocks.extend(get_course_assignment_due_dates(
|
||||
course, user, request, num_return=num_assignments, include_past_dates=include_past_dates))
|
||||
if DATE_WIDGET_V2_FLAG.is_enabled(course.id):
|
||||
blocks.append(CourseExpiredDate(course, user))
|
||||
blocks.extend(get_course_assignment_due_dates(
|
||||
course, user, request, num_return=num_assignments, include_past_dates=include_past_dates))
|
||||
|
||||
return sorted((b for b in blocks if b.date and (b.is_enabled or include_past_dates)), key=date_block_key_fn)
|
||||
|
||||
@@ -448,7 +449,7 @@ def get_course_assignment_due_dates(course, user, request, num_return=None, incl
|
||||
block_url = reverse('jump_to', args=[course.id, block_key])
|
||||
block_url = request.build_absolute_uri(block_url) if request else None
|
||||
assignment_title = item.display_name if item.display_name else _('Assignment')
|
||||
date_block.set_title(assignment_title, block_url)
|
||||
date_block.set_title(assignment_title, link=block_url)
|
||||
|
||||
date_blocks.append(date_block)
|
||||
date_blocks = sorted((b for b in date_blocks if b.is_enabled or include_past_dates), key=date_block_key_fn)
|
||||
|
||||
@@ -28,7 +28,7 @@ from openedx.core.djangoapps.certificates.api import can_show_certificate_availa
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
from openedx.features.course_duration_limits.access import get_user_course_expiration_date
|
||||
from openedx.features.course_duration_limits.models import CourseDurationLimitConfig
|
||||
from openedx.features.course_experience import UPGRADE_DEADLINE_MESSAGE, CourseHomeMessages
|
||||
from openedx.features.course_experience import DATE_WIDGET_V2_FLAG, UPGRADE_DEADLINE_MESSAGE, CourseHomeMessages
|
||||
from student.models import CourseEnrollment
|
||||
|
||||
from .context_processor import user_timezone_locale_prefs
|
||||
@@ -295,7 +295,7 @@ class CourseEndDate(DateSummary):
|
||||
|
||||
@property
|
||||
def date(self):
|
||||
if self.course.self_paced:
|
||||
if DATE_WIDGET_V2_FLAG.is_enabled(self.course_id) and self.course.self_paced:
|
||||
weeks_to_complete = get_course_run_details(self.course.id, ['weeks_to_complete']).get('weeks_to_complete')
|
||||
if weeks_to_complete:
|
||||
course_duration = datetime.timedelta(weeks=weeks_to_complete)
|
||||
|
||||
@@ -41,7 +41,9 @@ from openedx.core.djangoapps.site_configuration.tests.factories import SiteFacto
|
||||
from openedx.core.djangoapps.user_api.preferences.api import set_user_preference
|
||||
from openedx.core.djangoapps.waffle_utils.testutils import override_waffle_flag
|
||||
from openedx.features.course_duration_limits.models import CourseDurationLimitConfig
|
||||
from openedx.features.course_experience import UNIFIED_COURSE_TAB_FLAG, UPGRADE_DEADLINE_MESSAGE, CourseHomeMessages
|
||||
from openedx.features.course_experience import (
|
||||
DATE_WIDGET_V2_FLAG, UNIFIED_COURSE_TAB_FLAG, UPGRADE_DEADLINE_MESSAGE, CourseHomeMessages
|
||||
)
|
||||
from student.tests.factories import TEST_PASSWORD, CourseEnrollmentFactory, UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
@@ -132,6 +134,7 @@ class CourseDateSummaryTest(SharedModuleStoreTestCase):
|
||||
CourseEnrollmentFactory(course_id=course.id, user=user, mode=CourseMode.VERIFIED)
|
||||
self.assert_block_types(course, user, expected_blocks)
|
||||
|
||||
@override_waffle_flag(DATE_WIDGET_V2_FLAG, active=True)
|
||||
def test_enabled_block_types_with_assignments(self): # pylint: disable=too-many-statements
|
||||
"""
|
||||
Creates a course with multiple subsections to test all of the different
|
||||
@@ -286,6 +289,7 @@ class CourseDateSummaryTest(SharedModuleStoreTestCase):
|
||||
for html_tag in assignment_title_html:
|
||||
self.assertIn(html_tag, assignment_title)
|
||||
|
||||
@override_waffle_flag(DATE_WIDGET_V2_FLAG, active=True)
|
||||
def test_enabled_block_types_with_expired_course(self):
|
||||
course = create_course_run(days_till_start=-100)
|
||||
user = create_user()
|
||||
@@ -460,6 +464,7 @@ class CourseDateSummaryTest(SharedModuleStoreTestCase):
|
||||
{'weeks_to_complete': 7}, # Weeks to complete > time til end (end date shown)
|
||||
{'weeks_to_complete': 4}, # Weeks to complete < time til end (end date not shown)
|
||||
)
|
||||
@override_waffle_flag(DATE_WIDGET_V2_FLAG, active=True)
|
||||
def test_course_end_date_self_paced(self, cr_details):
|
||||
"""
|
||||
In self-paced courses, the end date will now only show up if the learner
|
||||
|
||||
Reference in New Issue
Block a user