update messaging
This commit is contained in:
committed by
Matthew Piatetsky
parent
b2b92308d8
commit
eaa07082ed
@@ -19,7 +19,7 @@ from lms.djangoapps.courseware.date_summary import verified_upgrade_deadline_lin
|
||||
from lms.djangoapps.lms_xblock.field_data import LmsFieldData
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from openedx.core.lib.url_utils import quote_slashes
|
||||
from student.models import Registration
|
||||
from student.models import Registration, CourseEnrollment
|
||||
from student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
from xblock.field_data import DictFieldData
|
||||
from xmodule.modulestore.django import modulestore
|
||||
@@ -358,12 +358,21 @@ def get_expiration_banner_text(user, course):
|
||||
Get text for banner that messages user course expiration date
|
||||
for different tests that depend on it.
|
||||
"""
|
||||
expiration_date = (now() + timedelta(weeks=4)).strftime('%b %-d')
|
||||
expiration_date = (now() + timedelta(weeks=4)).strftime('%b. %-d, %Y')
|
||||
upgrade_link = verified_upgrade_deadline_link(user=user, course=course)
|
||||
bannerText = 'Your access to this course expires on {expiration_date}. \
|
||||
<a href="{upgrade_link}">Upgrade now <span class="sr-only">to retain access past {expiration_date}.\
|
||||
</span></a><span aria-hidden="true">for unlimited access.</span>'.format(
|
||||
enrollment = CourseEnrollment.get_enrollment(user, course.id)
|
||||
upgrade_deadline = enrollment.upgrade_deadline
|
||||
if upgrade_deadline is None:
|
||||
return
|
||||
if now() < upgrade_deadline:
|
||||
upgrade_deadline = enrollment.course_upgrade_deadline
|
||||
bannerText = '<strong>Audit Access Expires {expiration_date}</strong><br>\
|
||||
You lose all access to this course, including your progress, on {expiration_date}.<br>\
|
||||
Upgrade by {upgrade_deadline} to get unlimited access to the course as long as it exists on the site.\
|
||||
<a href="{upgrade_link}">Upgrade now<span class="sr-only"> to retain access past {expiration_date}\
|
||||
</span></a>'.format(
|
||||
expiration_date=expiration_date,
|
||||
upgrade_link=upgrade_link
|
||||
upgrade_link=upgrade_link,
|
||||
upgrade_deadline=upgrade_deadline.strftime('%b. %-d, %Y')
|
||||
)
|
||||
return bannerText
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
.alert.alert-info a {
|
||||
// Need to have sufficient contrast for blue links on blue background
|
||||
// Based this on some existing css for this use case
|
||||
color: #245269;
|
||||
color: #0075b4;
|
||||
text-decoration: underline;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ from django.apps import apps
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from student.models import CourseEnrollment
|
||||
from util.date_utils import DEFAULT_SHORT_DATE_FORMAT, strftime_localized
|
||||
|
||||
from course_modes.models import CourseMode
|
||||
@@ -43,7 +44,7 @@ class AuditExpiredError(AccessError):
|
||||
)
|
||||
except CourseOverview.DoesNotExist:
|
||||
additional_context_user_message = _("Access to the course you were looking"
|
||||
"for expired on {expiration_date}").format(
|
||||
" for expired on {expiration_date}").format(
|
||||
expiration_date=expiration_date
|
||||
)
|
||||
super(AuditExpiredError, self).__init__(error_code, developer_message, user_message,
|
||||
@@ -130,12 +131,30 @@ def register_course_expired_message(request, course):
|
||||
)
|
||||
)
|
||||
else:
|
||||
upgrade_message = _('Your access to this course expires on {expiration_date}. \
|
||||
{a_open}Upgrade now {sronly_span_open}to retain access past {expiration_date}.\
|
||||
{span_close}{a_close}{sighted_only_span_open}for unlimited access.{span_close}')
|
||||
enrollment = CourseEnrollment.get_enrollment(request.user, course.id)
|
||||
if enrollment is None:
|
||||
return
|
||||
|
||||
upgrade_deadline = enrollment.upgrade_deadline
|
||||
if upgrade_deadline is None:
|
||||
return
|
||||
now = timezone.now()
|
||||
if now < upgrade_deadline:
|
||||
upgrade_deadline = enrollment.course_upgrade_deadline
|
||||
|
||||
expiration_message = _('{strong_open}Audit Access Expires {expiration_date}{strong_close}'
|
||||
'{line_break}You lose all access to this course, including your progress, on '
|
||||
'{expiration_date}.')
|
||||
upgrade_deadline_message = _('{line_break}Upgrade by {upgrade_deadline} to get unlimited access to the course '
|
||||
'as long as it exists on the site. {a_open}Upgrade now{sronly_span_open} to '
|
||||
'retain access past {expiration_date}{span_close}{a_close}')
|
||||
full_message = expiration_message
|
||||
if now < upgrade_deadline:
|
||||
full_message += upgrade_deadline_message
|
||||
|
||||
PageLevelMessages.register_info_message(
|
||||
request,
|
||||
Text(upgrade_message).format(
|
||||
Text(full_message).format(
|
||||
a_open=HTML('<a href="{upgrade_link}">').format(
|
||||
upgrade_link=verified_upgrade_deadline_link(user=request.user, course=course)
|
||||
),
|
||||
@@ -143,6 +162,10 @@ def register_course_expired_message(request, course):
|
||||
sighted_only_span_open=HTML('<span aria-hidden="true">'),
|
||||
span_close=HTML('</span>'),
|
||||
a_close=HTML('</a>'),
|
||||
expiration_date=expiration_date.strftime('%b %-d'),
|
||||
expiration_date=expiration_date.strftime('%b. %-d, %Y'),
|
||||
strong_open=HTML('<strong>'),
|
||||
strong_close=HTML('</strong>'),
|
||||
line_break=HTML('<br>'),
|
||||
upgrade_deadline=upgrade_deadline.strftime('%b. %-d, %Y')
|
||||
)
|
||||
)
|
||||
|
||||
@@ -180,7 +180,7 @@ class CourseExpirationTestCase(ModuleStoreTestCase):
|
||||
response = self.client.get(course_home_url, follow=True)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertItemsEqual(response.redirect_chain, [])
|
||||
banner_text = 'Your access to this course expires on'
|
||||
banner_text = 'You lose all access to this course, including your progress,'
|
||||
if show_expiration_banner:
|
||||
self.assertIn(banner_text, response.content)
|
||||
else:
|
||||
@@ -245,7 +245,7 @@ class CourseExpirationTestCase(ModuleStoreTestCase):
|
||||
response = self.client.get(course_home_url, follow=True)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertItemsEqual(response.redirect_chain, [])
|
||||
banner_text = 'Your access to this course expires on'
|
||||
banner_text = 'You lose all access to this course, including your progress,'
|
||||
self.assertNotIn(banner_text, response.content)
|
||||
|
||||
@mock.patch("openedx.features.course_duration_limits.access.get_course_run_details")
|
||||
|
||||
Reference in New Issue
Block a user