Commit a9960e93 by Eric Fischer Committed by GitHub

Merge pull request #14019 from edx/efischer/verify_times

Localize times in verify_student
parents be7f6ecb 1aff2290
...@@ -725,7 +725,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin): ...@@ -725,7 +725,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin):
# Expect that the expiration date is set # Expect that the expiration date is set
response = self._get_page(payment_flow, course.id) response = self._get_page(payment_flow, course.id)
data = self._get_page_data(response) data = self._get_page_data(response)
self.assertEqual(data['verification_deadline'], deadline.strftime("%b %d, %Y at %H:%M UTC")) self.assertEqual(data['verification_deadline'], unicode(deadline))
def test_course_mode_expired(self): def test_course_mode_expired(self):
deadline = datetime.now(tz=pytz.UTC) + timedelta(days=-360) deadline = datetime.now(tz=pytz.UTC) + timedelta(days=-360)
...@@ -743,7 +743,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin): ...@@ -743,7 +743,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin):
# to the student that the deadline has passed # to the student that the deadline has passed
response = self._get_page("verify_student_verify_now", course.id) response = self._get_page("verify_student_verify_now", course.id)
self.assertContains(response, "verification deadline") self.assertContains(response, "verification deadline")
self.assertContains(response, deadline.strftime("%b %d, %Y at %H:%M UTC")) self.assertContains(response, deadline)
@ddt.data(datetime.now(tz=pytz.UTC) + timedelta(days=360), None) @ddt.data(datetime.now(tz=pytz.UTC) + timedelta(days=360), None)
def test_course_mode_expired_verification_deadline_in_future(self, verification_deadline): def test_course_mode_expired_verification_deadline_in_future(self, verification_deadline):
...@@ -792,7 +792,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin): ...@@ -792,7 +792,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin):
# Check that the verification deadline (rather than the upgrade deadline) is displayed # Check that the verification deadline (rather than the upgrade deadline) is displayed
if verification_deadline is not None: if verification_deadline is not None:
self.assertEqual(data["verification_deadline"], verification_deadline.strftime("%b %d, %Y at %H:%M UTC")) self.assertEqual(data["verification_deadline"], unicode(verification_deadline))
else: else:
self.assertEqual(data["verification_deadline"], "") self.assertEqual(data["verification_deadline"], "")
...@@ -821,7 +821,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin): ...@@ -821,7 +821,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin):
# message when we go to verify. # message when we go to verify.
response = self._get_page("verify_student_verify_now", course.id) response = self._get_page("verify_student_verify_now", course.id)
self.assertContains(response, "verification deadline") self.assertContains(response, "verification deadline")
self.assertContains(response, verification_deadline_in_past.strftime("%b %d, %Y at %H:%M UTC")) self.assertContains(response, verification_deadline_in_past)
@mock.patch.dict(settings.FEATURES, {'EMBARGO': True}) @mock.patch.dict(settings.FEATURES, {'EMBARGO': True})
@ddt.data("verify_student_start_flow", "verify_student_begin_flow") @ddt.data("verify_student_start_flow", "verify_student_begin_flow")
......
...@@ -424,10 +424,7 @@ class PayAndVerifyView(View): ...@@ -424,10 +424,7 @@ class PayAndVerifyView(View):
'processors': processors, 'processors': processors,
'requirements': requirements, 'requirements': requirements,
'user_full_name': full_name, 'user_full_name': full_name,
'verification_deadline': ( 'verification_deadline': verification_deadline or "",
get_default_time_display(verification_deadline)
if verification_deadline else ""
),
'already_verified': already_verified, 'already_verified': already_verified,
'verification_good_until': verification_good_until, 'verification_good_until': verification_good_until,
'capture_sound': staticfiles_storage.url("audio/camera_capture.wav"), 'capture_sound': staticfiles_storage.url("audio/camera_capture.wav"),
...@@ -697,10 +694,7 @@ class PayAndVerifyView(View): ...@@ -697,10 +694,7 @@ class PayAndVerifyView(View):
context = { context = {
'course': course, 'course': course,
'deadline_name': deadline_name, 'deadline_name': deadline_name,
'deadline': ( 'deadline': deadline_datetime
get_default_time_display(deadline_datetime)
if deadline_datetime else ""
)
} }
return render_to_response("verify_student/missed_deadline.html", context) return render_to_response("verify_student/missed_deadline.html", context)
......
...@@ -142,25 +142,26 @@ define([ ...@@ -142,25 +142,26 @@ define([
}); });
it('view containing verification msg when verification deadline is set and user is active', function() { it('view containing verification msg when verification deadline is set and user is active', function() {
var verificationDeadlineDateFormat = 'Aug 14, 2016 at 23:59 UTC'; var verificationDeadline = '2016-08-14 23:59:00+00:00';
createView({ createView({
userEmail: 'test@example.com', userEmail: 'test@example.com',
userTimezone: 'PDT',
userLanguage: 'es-ES',
requirements: { requirements: {
isVisible: true isVisible: true
}, },
verificationDeadline: verificationDeadlineDateFormat, verificationDeadline: verificationDeadline,
isActive: true isActive: true
}); });
// Verify user does not get user activation message when he is already activated. // Verify user does not get user activation message when he is already activated.
expect($('p.instruction-info:contains("test@example.com")').length).toEqual(0); expect($('p.instruction-info:contains("test@example.com")').length).toEqual(0);
// Verify user gets verification message. // Verify user gets verification message.
expect( expect($('p.localized-datetime').attr('data-string')).toEqual(
$( 'You can pay now even if you don\'t have the following items available,' +
'p.instruction-info:contains("You can pay now even if you don\'t have ' + ' but you will need to have these by {date} to qualify to earn a Verified Certificate.'
'the following items available, but you will need to have these by ' + );
verificationDeadlineDateFormat + ' to qualify to earn a Verified Certificate.")' expect($('p.localized-datetime').attr('data-timezone')).toEqual('PDT');
).length expect($('p.localized-datetime').attr('data-language')).toEqual('es-ES');
).toEqual(1);
}); });
it('view containing user email when verification deadline is set and user is not active', function() { it('view containing user email when verification deadline is set and user is not active', function() {
......
...@@ -50,6 +50,8 @@ var edx = edx || {}; ...@@ -50,6 +50,8 @@ var edx = edx || {};
courseKey: el.data('course-key'), courseKey: el.data('course-key'),
courseName: el.data('course-name'), courseName: el.data('course-name'),
userEmail: el.data('user-email'), userEmail: el.data('user-email'),
userLanguage: el.data('user-language'),
userTimezone: el.data('user-timezone'),
hasVisibleReqs: _.some( hasVisibleReqs: _.some(
el.data('requirements'), el.data('requirements'),
function(isVisible) { return isVisible; } function(isVisible) { return isVisible; }
......
...@@ -30,6 +30,8 @@ var edx = edx || {}; ...@@ -30,6 +30,8 @@ var edx = edx || {};
currency: 'usd', currency: 'usd',
upgrade: false, upgrade: false,
verificationDeadline: '', verificationDeadline: '',
userTimezone: 'UTC',
userLanguage: 'en-US',
courseName: '', courseName: '',
requirements: {}, requirements: {},
hasVisibleReqs: false, hasVisibleReqs: false,
......
...@@ -31,10 +31,13 @@ ...@@ -31,10 +31,13 @@
<% if ( _.some( requirements, function( isVisible ) { return isVisible; } ) ) { %> <% if ( _.some( requirements, function( isVisible ) { return isVisible; } ) ) { %>
<p class="instruction-info"> <p class="instruction-info">
<% if ( verificationDeadline && isActive) { %> <% if ( verificationDeadline && isActive) { %>
<%- _.sprintf( <p
gettext( "You can pay now even if you don't have the following items available, but you will need to have these by %(date)s to qualify to earn a Verified Certificate." ), class="localized-datetime"
{ date: verificationDeadline } data-datetime="<%-verificationDeadline%>"
) %> data-string="<%-gettext( "You can pay now even if you don't have the following items available, but you will need to have these by {date} to qualify to earn a Verified Certificate." )%>"
data-timezone="<%-userTimezone%>"
data-language="<%-userLanguage%>"
>
<% } else if ( !isActive ) { %> <% } else if ( !isActive ) { %>
<i class="fa fa-envelope-o" aria-hidden="true"></i> <i class="fa fa-envelope-o" aria-hidden="true"></i>
<%= HtmlUtils.interpolateHtml( <%= HtmlUtils.interpolateHtml(
......
...@@ -74,10 +74,13 @@ ...@@ -74,10 +74,13 @@
<% if ( _.some( requirements, function( isVisible ) { return isVisible; } ) ) { %> <% if ( _.some( requirements, function( isVisible ) { return isVisible; } ) ) { %>
<p> <p>
<% if ( verificationDeadline ) { %> <% if ( verificationDeadline ) { %>
<%- _.sprintf( <p
gettext( "To receive a certificate, you must also verify your identity before %(date)s." ), class="localized-datetime"
{ date: verificationDeadline } data-datetime="<%-verificationDeadline%>"
) %> data-string="<%-gettext( "To receive a certificate, you must also verify your identity before {date}." )%>"
data-timezone="<%-userTimezone%>"
data-language="<%-userLanguage%>"
>
<% } else { %> <% } else { %>
<%- gettext( "To receive a certificate, you must also verify your identity." ) %> <%- gettext( "To receive a certificate, you must also verify your identity." ) %>
<% } %> <% } %>
......
...@@ -16,15 +16,27 @@ from lms.djangoapps.verify_student.views import PayAndVerifyView ...@@ -16,15 +16,27 @@ from lms.djangoapps.verify_student.views import PayAndVerifyView
</%block> </%block>
<%block name="content"> <%block name="content">
<section class="outside-app"> <section class="outside-app">
<p> <p
class="localized-datetime"
data-datetime="${deadline}"
data-timezone="${user_timezone}"
data-language="${user_language}"
% if deadline_name == PayAndVerifyView.VERIFICATION_DEADLINE: % if deadline_name == PayAndVerifyView.VERIFICATION_DEADLINE:
${_(u"The verification deadline for {course_name} was {date}. Verification is no longer available.").format( data-string="${
course_name=course.display_name, date=deadline)} _(
u'The verification deadline for {course_name} was {{date}}. Verification is no longer available.'
).format(
course_name=course.display_name
)
}"
% elif deadline_name == PayAndVerifyView.UPGRADE_DEADLINE: % elif deadline_name == PayAndVerifyView.UPGRADE_DEADLINE:
${_(u"The deadline to upgrade to a verified certificate for this course has passed.")} data-string="${_(u'The deadline to upgrade to a verified certificate for this course has passed.')}"
% endif % endif
>
</p> </p>
</section> </section>
</%block> </%block>
<%static:require_module_async module_name="js/dateutil_factory" class_name="DateUtilFactory">
DateUtilFactory.transform(iterationKey=".localized-datetime");
</%static:require_module_async>
...@@ -82,6 +82,8 @@ from lms.djangoapps.verify_student.views import PayAndVerifyView ...@@ -82,6 +82,8 @@ from lms.djangoapps.verify_student.views import PayAndVerifyView
data-msg-key='${message_key}' data-msg-key='${message_key}'
data-is-active='${is_active}' data-is-active='${is_active}'
data-user-email='${user_email}' data-user-email='${user_email}'
data-user-language='${user_language}'
data-user-timezone='${user_timezone}'
data-already-verified='${already_verified}' data-already-verified='${already_verified}'
data-verification-good-until='${verification_good_until}' data-verification-good-until='${verification_good_until}'
data-capture-sound='${capture_sound}' data-capture-sound='${capture_sound}'
...@@ -122,3 +124,6 @@ from lms.djangoapps.verify_student.views import PayAndVerifyView ...@@ -122,3 +124,6 @@ from lms.djangoapps.verify_student.views import PayAndVerifyView
</section> </section>
</div> </div>
</%block> </%block>
<%static:require_module_async module_name="js/dateutil_factory" class_name="DateUtilFactory">
DateUtilFactory.transform(iterationKey=".localized-datetime");
</%static:require_module_async>
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