Merge pull request #18770 from edx/LEARNER-3325/cert-generation-message
Certificate messages must be dependent on active web configurations
This commit is contained in:
@@ -26,6 +26,7 @@ from django.http import Http404, QueryDict
|
||||
from enrollment.api import get_course_enrollment_details
|
||||
from edxmako.shortcuts import render_to_string
|
||||
from fs.errors import ResourceNotFound
|
||||
from lms.djangoapps.certificates import api as certs_api
|
||||
from lms.djangoapps.courseware.courseware_access_exception import CoursewareAccessException
|
||||
from lms.djangoapps.courseware.exceptions import CourseAccessRedirect
|
||||
from opaque_keys.edx.keys import UsageKey
|
||||
@@ -370,14 +371,15 @@ def get_course_date_blocks(course, user):
|
||||
Return the list of blocks to display on the course info page,
|
||||
sorted by date.
|
||||
"""
|
||||
block_classes = (
|
||||
CertificateAvailableDate,
|
||||
block_classes = [
|
||||
CourseEndDate,
|
||||
CourseStartDate,
|
||||
TodaysDate,
|
||||
VerificationDeadlineDate,
|
||||
VerifiedUpgradeDeadlineDate,
|
||||
)
|
||||
]
|
||||
if certs_api.get_active_web_certificate(course):
|
||||
block_classes.insert(0, CertificateAvailableDate)
|
||||
|
||||
blocks = (cls(course, user) for cls in block_classes)
|
||||
|
||||
|
||||
@@ -1326,6 +1326,7 @@ class ProgressPageTests(ProgressPageBaseTests):
|
||||
resp = self._get_progress_page()
|
||||
self.assertNotContains(resp, 'Request Certificate')
|
||||
|
||||
@patch('lms.djangoapps.certificates.api.get_active_web_certificate', PropertyMock(return_value=True))
|
||||
@patch.dict('django.conf.settings.FEATURES', {'CERTIFICATES_HTML_VIEW': True})
|
||||
def test_view_certificate_link(self):
|
||||
"""
|
||||
@@ -1389,9 +1390,10 @@ class ProgressPageTests(ProgressPageBaseTests):
|
||||
resp = self._get_progress_page()
|
||||
self.assertNotContains(resp, u"View Your Certificate")
|
||||
self.assertNotContains(resp, u"You can now view your certificate")
|
||||
self.assertContains(resp, "working on it...")
|
||||
self.assertContains(resp, "creating your certificate")
|
||||
self.assertContains(resp, "Your certificate is available")
|
||||
self.assertContains(resp, "earned a certificate for this course.")
|
||||
|
||||
@patch('lms.djangoapps.certificates.api.get_active_web_certificate', PropertyMock(return_value=True))
|
||||
@patch.dict('django.conf.settings.FEATURES', {'CERTIFICATES_HTML_VIEW': False})
|
||||
def test_view_certificate_link_hidden(self):
|
||||
"""
|
||||
@@ -1458,6 +1460,7 @@ class ProgressPageTests(ProgressPageBaseTests):
|
||||
), check_mongo_calls(1):
|
||||
self._get_progress_page()
|
||||
|
||||
@patch('lms.djangoapps.certificates.api.get_active_web_certificate', PropertyMock(return_value=True))
|
||||
@ddt.data(
|
||||
*itertools.product(
|
||||
(
|
||||
@@ -1589,6 +1592,7 @@ class ProgressPageTests(ProgressPageBaseTests):
|
||||
self.assertContains(resp, u"View Certificate")
|
||||
self.assert_invalidate_certificate(generated_certificate)
|
||||
|
||||
@patch('lms.djangoapps.certificates.api.get_active_web_certificate', PropertyMock(return_value=True))
|
||||
def test_page_with_invalidated_certificate_with_pdf(self):
|
||||
"""
|
||||
Verify that for pdf certs if certificate is marked as invalidated than
|
||||
@@ -1613,6 +1617,7 @@ class ProgressPageTests(ProgressPageBaseTests):
|
||||
self.assert_invalidate_certificate(generated_certificate)
|
||||
|
||||
@patch('courseware.views.views.is_course_passed', PropertyMock(return_value=True))
|
||||
@patch('lms.djangoapps.certificates.api.get_active_web_certificate', PropertyMock(return_value=True))
|
||||
def test_message_for_audit_mode(self):
|
||||
""" Verify that message appears on progress page, if learner is enrolled
|
||||
in audit mode.
|
||||
@@ -1634,6 +1639,7 @@ class ProgressPageTests(ProgressPageBaseTests):
|
||||
)
|
||||
|
||||
@patch('courseware.views.views.is_course_passed', PropertyMock(return_value=True))
|
||||
@patch('lms.djangoapps.certificates.api.get_active_web_certificate', PropertyMock(return_value=True))
|
||||
def test_message_for_honor_mode(self):
|
||||
""" Verify that message appears on progress page, if learner is enrolled
|
||||
in honor mode.
|
||||
|
||||
@@ -993,8 +993,9 @@ def _progress(request, course_key, student_id):
|
||||
'supports_preview_menu': True,
|
||||
'student': student,
|
||||
'credit_course_requirements': _credit_course_requirements(course_key, student),
|
||||
'certificate_data': _get_cert_data(student, course, enrollment_mode, course_grade),
|
||||
}
|
||||
if certs_api.get_active_web_certificate(course):
|
||||
context['certificate_data'] = _get_cert_data(student, course, enrollment_mode, course_grade)
|
||||
context.update(
|
||||
get_experiment_user_metadata_context(
|
||||
course,
|
||||
|
||||
Reference in New Issue
Block a user