Commit dbfdff09 by Sofiya Semenova

Checking if CAD exists before using it

parent 27a73f77
......@@ -121,19 +121,27 @@ class CertificateDashboardMessageDisplayTest(CertificateDisplayTestBase):
def _check_message(self, certificate_available_date):
response = self.client.get(reverse('dashboard'))
if datetime.datetime.now(UTC) < certificate_available_date:
if certificate_available_date is None:
self.assertNotContains(response, u"Your certificate will be available on")
self.assertNotContains(response, u"View Test_Certificate")
elif datetime.datetime.now(UTC) < certificate_available_date:
self.assertContains(response, u"Your certificate will be available on")
self.assertNotContains(response, u"View Test_Certificate")
else:
self._check_can_download_certificate()
@ddt.data(False)
@ddt.data(True, False, None)
def test_certificate_available_date(self, past_certificate_available_date):
cert = self._create_certificate('verified')
cert.status = CertificateStatuses.downloadable
cert.save()
certificate_available_date = PAST_DATE if past_certificate_available_date else FUTURE_DATE
if past_certificate_available_date is None:
certificate_available_date = None
elif past_certificate_available_date:
certificate_available_date = PAST_DATE
elif not past_certificate_available_date:
certificate_available_date = FUTURE_DATE
self.course.certificate_available_date = certificate_available_date
self.course.save()
......
......@@ -31,9 +31,9 @@ else:
%>
% if cert_status['status'] != 'processing':
<div class="message message-status ${status_css_class} is-shown">
% if not cert_status['certificate_message_viewable']:
% if (cert_status['status'] == 'generating' or cert_status['status'] == 'downloadable'):
% 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')
......@@ -42,8 +42,10 @@ else:
%>
<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>
% endif
% else:
</div>
% endif
% else:
<div class="message message-status ${status_css_class} is-shown">
<p class="message-copy">${_("Your final grade:")}
<span class="grade-value">${"{0:.0f}%".format(float(cert_status['grade'])*100)}</span>.
......@@ -143,7 +145,7 @@ else:
</div>
% endif
% endif
</div>
</div>
% endif
% endif
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