Commit 7382fe12 by Sofiya Semenova Committed by GitHub

Merge pull request #16203 from edx/ssemenova/dashboard-cert-info

Clean up dashboard_certificate_information template.
parents 1dc9b119 b8d73df5
......@@ -57,10 +57,9 @@ class TestStudentDashboardUnenrollments(SharedModuleStoreTestCase):
return {
'status': self.cert_status,
'can_unenroll': self.cert_status not in DISABLE_UNENROLL_CERT_STATES,
'certificate_message_viewable': True,
'download_url': 'fake_url',
'linked_in_url': False,
'grade': 100,
'show_disabled_download_button': False,
'show_download_url': False,
'show_survey_button': False
}
......
......@@ -83,9 +83,6 @@ class CourseEndingTest(TestCase):
_cert_info(user, course, None, course_mode),
{
'status': 'processing',
'show_disabled_download_button': False,
'certificate_message_viewable': False,
'show_download_url': False,
'show_survey_button': False,
'can_unenroll': True,
}
......@@ -96,9 +93,6 @@ class CourseEndingTest(TestCase):
_cert_info(user, course, cert_status, course_mode),
{
'status': 'processing',
'show_disabled_download_button': False,
'certificate_message_viewable': True,
'show_download_url': False,
'show_survey_button': False,
'mode': None,
'linked_in_url': None,
......@@ -113,9 +107,6 @@ class CourseEndingTest(TestCase):
_cert_info(user, course, cert_status, course_mode),
{
'status': 'generating',
'show_disabled_download_button': True,
'certificate_message_viewable': True,
'show_download_url': False,
'show_survey_button': True,
'survey_url': survey_url,
'grade': '1.0',
......@@ -130,9 +121,6 @@ class CourseEndingTest(TestCase):
_cert_info(user, course, cert_status, course_mode),
{
'status': 'generating',
'show_disabled_download_button': True,
'certificate_message_viewable': True,
'show_download_url': False,
'show_survey_button': True,
'survey_url': survey_url,
'grade': '0.67',
......@@ -154,9 +142,6 @@ class CourseEndingTest(TestCase):
_cert_info(user, course, cert_status, course_mode),
{
'status': 'downloadable',
'show_disabled_download_button': False,
'certificate_message_viewable': True,
'show_download_url': True,
'download_url': download_url,
'show_survey_button': True,
'survey_url': survey_url,
......@@ -176,9 +161,6 @@ class CourseEndingTest(TestCase):
_cert_info(user, course, cert_status, course_mode),
{
'status': 'notpassing',
'show_disabled_download_button': False,
'certificate_message_viewable': True,
'show_download_url': False,
'show_survey_button': True,
'survey_url': survey_url,
'grade': '0.67',
......@@ -198,9 +180,6 @@ class CourseEndingTest(TestCase):
_cert_info(user, course2, cert_status, course_mode),
{
'status': 'notpassing',
'show_disabled_download_button': False,
'certificate_message_viewable': True,
'show_download_url': False,
'show_survey_button': False,
'grade': '0.67',
'mode': 'honor',
......@@ -212,14 +191,28 @@ class CourseEndingTest(TestCase):
# test when the display is unavailable or notpassing, we get the correct results out
course2.certificates_display_behavior = 'early_no_info'
cert_status = {'status': 'unavailable'}
self.assertEqual(_cert_info(user, course2, cert_status, course_mode), {})
self.assertEqual(
_cert_info(user, course2, cert_status, course_mode),
{
'status': 'processing',
'show_survey_button': False,
'can_unenroll': True,
}
)
cert_status = {
'status': 'notpassing', 'grade': '0.67',
'download_url': download_url,
'mode': 'honor'
}
self.assertEqual(_cert_info(user, course2, cert_status, course_mode), {})
self.assertEqual(
_cert_info(user, course2, cert_status, course_mode),
{
'status': 'processing',
'show_survey_button': False,
'can_unenroll': True,
}
)
@ddt.data(
(0.70, 0.60),
......@@ -258,9 +251,6 @@ class CourseEndingTest(TestCase):
_cert_info(user, course, cert_status, course_mode),
{
'status': 'generating',
'show_disabled_download_button': True,
'certificate_message_viewable': True,
'show_download_url': False,
'show_survey_button': True,
'survey_url': survey_url,
'grade': unicode(expected_grade),
......@@ -292,9 +282,6 @@ class CourseEndingTest(TestCase):
_cert_info(user, course, cert_status, course_mode),
{
'status': 'processing',
'certificate_message_viewable': False,
'show_disabled_download_button': False,
'show_download_url': False,
'show_survey_button': False,
'can_unenroll': True,
}
......
......@@ -234,11 +234,9 @@ def cert_info(user, course_overview, course_mode):
Returns:
dict: A dictionary with keys:
'status': one of 'generating', 'downloadable', 'notpassing', 'processing', 'restricted'
'show_download_url': bool
'certificate_message_viewable': bool -- if certificates are viewable
'status': one of 'generating', 'downloadable', 'notpassing', 'processing', 'restricted', 'unavailable', or
'certificate_earned_but_not_available'
'download_url': url, only present if show_download_url is True
'show_disabled_download_button': bool -- true if state is 'generating'
'show_survey_button': bool
'survey_url': url, only if show_survey_button is True
'grade': if status is not 'processing'
......@@ -359,13 +357,11 @@ def _cert_info(user, course_overview, cert_status, course_mode): # pylint: disa
CertificateStatuses.unverified: 'unverified',
}
certificate_earned_but_not_available_status = 'certificate_earned_but_not_available'
default_status = 'processing'
default_info = {
'status': default_status,
'certificate_message_viewable': False,
'show_disabled_download_button': False,
'show_download_url': False,
'show_survey_button': False,
'can_unenroll': True,
}
......@@ -373,25 +369,30 @@ def _cert_info(user, course_overview, cert_status, course_mode): # pylint: disa
if cert_status is None:
return default_info
is_hidden_status = cert_status['status'] in ('unavailable', 'processing', 'generating', 'notpassing', 'auditing')
status = template_state.get(cert_status['status'], default_status)
is_hidden_status = status in ('unavailable', 'processing', 'generating', 'notpassing', 'auditing')
if course_overview.certificates_display_behavior == 'early_no_info' and is_hidden_status:
return {}
if (
not certificates_viewable_for_course(course_overview) and
(status in CertificateStatuses.PASSED_STATUSES) and
course_overview.certificate_available_date
):
status = certificate_earned_but_not_available_status
status = template_state.get(cert_status['status'], default_status)
if (
course_overview.certificates_display_behavior == 'early_no_info' and
is_hidden_status
):
return default_info
status_dict = {
'status': status,
'certificate_message_viewable': certificates_viewable_for_course(course_overview),
'show_download_url': status == 'downloadable',
'show_disabled_download_button': status == 'generating',
'mode': cert_status.get('mode', None),
'linked_in_url': None,
'can_unenroll': status not in DISABLE_UNENROLL_CERT_STATES,
}
if (status in ('generating', 'downloadable', 'notpassing', 'restricted', 'auditing', 'unverified') and
course_overview.end_of_course_survey_url is not None):
if not status == default_status and course_overview.end_of_course_survey_url is not None:
status_dict.update({
'show_survey_button': True,
'survey_url': process_survey_link(course_overview.end_of_course_survey_url, user)})
......@@ -408,7 +409,7 @@ def _cert_info(user, course_overview, cert_status, course_mode): # pylint: disa
})
else:
# don't show download certificate button if we don't have an active certificate for course
status_dict['show_download_url'] = False
status_dict['status'] = 'unavailable'
elif 'download_url' not in cert_status:
log.warning(
u"User %s has a downloadable cert for %s, but no download url",
......
......@@ -18,7 +18,7 @@ from course_modes.models import CourseMode
%>
<%
if (cert_status['status'] == 'generating' or cert_status['status'] == 'downloadable') and not cert_status['certificate_message_viewable']:
if cert_status['status'] == 'certificate_earned_but_not_available':
status_css_class = 'course-status-processing'
elif cert_status['status'] == 'generating':
status_css_class = 'course-status-certrendering'
......@@ -31,19 +31,17 @@ else:
%>
% if cert_status['status'] != 'processing':
% if not cert_status['certificate_message_viewable']:
% if (cert_status['status'] == 'generating' or cert_status['status'] == 'downloadable') and course_overview.certificate_available_date:
<div class="message message-status ${status_css_class} is-shown">
<p class="message-copy">
<%
certificate_available_date_string = course_overview.certificate_available_date.strftime('%Y-%m-%dT%H:%M:%S%z')
container_string = _("Your certificate will be available on or before {date}")
format = 'shortDate'
%>
<span class="info-date-block localized-datetime" data-language="${user_language}" data-timezone="${user_timezone}" data-datetime="${certificate_available_date_string}" data-format=${format} data-string="${container_string}"></span>
</p>
</div>
% endif
% if cert_status['status'] == 'certificate_earned_but_not_available':
<div class="message message-status ${status_css_class} is-shown">
<p class="message-copy">
<%
certificate_available_date_string = course_overview.certificate_available_date.strftime('%Y-%m-%dT%H:%M:%S%z')
container_string = _("Your certificate will be available on or before {date}")
format = 'shortDate'
%>
<span class="info-date-block localized-datetime" data-language="${user_language}" data-timezone="${user_timezone}" data-datetime="${certificate_available_date_string}" data-format=${format} data-string="${container_string}"></span>
</p>
</div>
% else:
<div class="message message-status ${status_css_class} is-shown">
<p class="message-copy">${_("Your final grade:")}
......@@ -73,37 +71,37 @@ else:
</p>
% if cert_status['show_disabled_download_button'] or cert_status['show_download_url'] or cert_status['show_survey_button']:
% if cert_status['status'] == 'generating' or cert_status['status'] == 'downloadable' or cert_status['show_survey_button']:
<div class="wrapper-message-primary">
<ul class="actions actions-primary">
% if cert_status['show_disabled_download_button']:
% if cert_status['status'] == 'generating':
<li class="action">
<span class="disabled">
${_("Your {cert_name_short} is Generating").format(cert_name_short=cert_name_short)}
</span>
</li>
% elif cert_status['show_download_url'] and cert_status.get('show_cert_web_view', False):
% elif cert_status['status'] == 'downloadable' and cert_status.get('show_cert_web_view', False):
<li class="action action-certificate">
<a class="btn" href="${cert_status['cert_web_view_url']}" target="_blank"
title="${_('This link will open the certificate web view')}">
${_("View {cert_name_short}").format(cert_name_short=cert_name_short,)}
</a>
</li>
% elif cert_status['show_download_url'] and enrollment.mode in CourseMode.NON_VERIFIED_MODES:
% elif cert_status['status'] == 'downloadable' and enrollment.mode in CourseMode.NON_VERIFIED_MODES:
<li class="action action-certificate">
<a class="btn" href="${cert_status['download_url']}"
title="${_('This link will open/download a PDF document')}">
${_("Download {cert_name_short} (PDF)").format(cert_name_short=cert_name_short,)}
</a>
</li>
% elif cert_status['show_download_url'] and enrollment.mode == 'verified' and cert_status['mode'] == 'honor':
% elif cert_status['status'] == 'downloadable' and enrollment.mode == 'verified' and cert_status['mode'] == 'honor':
<li class="action">
<a class="btn" href="${cert_status['download_url']}"
title="${_('This link will open/download a PDF document')}">
${_("Download Your {cert_name_short} (PDF)").format(cert_name_short=cert_name_short)}
</a>
</li>
% elif cert_status['show_download_url'] and enrollment.mode in CourseMode.VERIFIED_MODES:
% elif cert_status['status'] == 'downloadable' and enrollment.mode in CourseMode.VERIFIED_MODES:
<li class="action">
<a class="btn" href="${cert_status['download_url']}"
title="${_('This link will open/download a PDF document of your verified {cert_name_long}.').format(cert_name_long=cert_name_long)}">
......@@ -122,7 +120,7 @@ else:
</ul>
</div>
% if cert_status['show_download_url'] and cert_status['linked_in_url']:
% if cert_status['status'] == 'downloadable' and cert_status['linked_in_url']:
<ul class="actions actions-secondary">
<li class="action action-share">
<a class="action-linkedin-profile" target="_blank" href="${cert_status['linked_in_url']}"
......@@ -139,7 +137,7 @@ else:
% endif
% endif
% if cert_status['show_download_url'] and cert_status['certificate_message_viewable'] and enrollment.mode == 'verified' and cert_status['mode'] == 'honor':
% if cert_status['status'] == 'downloadable' and enrollment.mode == 'verified' and cert_status['mode'] == 'honor':
<div class="certificate-explanation">
${_('Since we did not have a valid set of verification photos from you when your {cert_name_long} was generated, we could not grant you a verified {cert_name_short}. An honor code {cert_name_short} has been granted instead.').format(cert_name_short=cert_name_short, cert_name_long=cert_name_long)}
</div>
......
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