Commit 729127c3 by Gregory Martin Committed by GitHub

Merge pull request #15920 from edx/yro/disable_nocertificate_date

Deactivate date display if no cert active
parents e56966c1 43e14b91
......@@ -803,7 +803,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
"""
self.course.self_paced = is_self_paced
self.course.save()
self._add_course_certificates(count=1, signatory_count=1)
self._add_course_certificates(count=1, signatory_count=1, is_active=True)
test_url = get_certificate_url(
user_id=self.user.id,
course_id=unicode(self.course.id)
......
......@@ -204,15 +204,25 @@ class CertificateAvailableDate(DateSummary):
title = ugettext_lazy('Certificate Available')
@property
def active_certificates(self):
return [
certificate for certificate in self.course.certificates.get('certificates', [])
if certificate.get('is_active', False)
]
@property
def is_enabled(self):
return (
self.date is not None and datetime.datetime.now(utc) <= self.date and not self.course.self_paced and
waffle.waffle().is_enabled(waffle.INSTRUCTOR_PACED_ONLY)
self.date is not None and
datetime.datetime.now(utc) <= self.date and
not self.course.self_paced and
waffle.waffle().is_enabled(waffle.INSTRUCTOR_PACED_ONLY) and
len(self.active_certificates) > 0
)
@property
def description(self):
return _('Day certificates will become available for passing verified learners.')
return _('Day certificates will become available for passing verified learners.' + str(self.active_certificates))
@property
def date(self):
......
......@@ -382,6 +382,13 @@ class CourseDateSummaryTest(SharedModuleStoreTestCase):
verified_user = self.create_user()
CourseEnrollmentFactory(course_id=course.id, user=verified_user, mode=CourseMode.VERIFIED)
course.certificate_available_date = datetime.now(utc) + timedelta(days=7)
course.certificates = {
u'certificates': [{
u'course_title': u'Test',
u'name': u'',
u'is_active': True,
}]
}
course.save()
CertificateAvailableDate(course, audit_user)
for block in (CertificateAvailableDate(course, audit_user), CertificateAvailableDate(course, verified_user)):
......
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