Don't show certificate on profile if no active config.
Stop showing certificate information on profile page if there is no active certificate configuration. PROD-1200
This commit is contained in:
@@ -290,6 +290,7 @@ def certificate_downloadable_status(student, course_key):
|
||||
if current_status['status'] == CertificateStatuses.downloadable and may_view_certificate:
|
||||
response_data['is_downloadable'] = True
|
||||
response_data['download_url'] = current_status['download_url'] or get_certificate_url(student.id, course_key)
|
||||
response_data['is_pdf_certificate'] = bool(current_status['download_url'])
|
||||
response_data['uuid'] = current_status['uuid']
|
||||
|
||||
return response_data
|
||||
|
||||
@@ -173,6 +173,7 @@ class CertificateDownloadableStatusTests(WebCertificateTestMixin, ModuleStoreTes
|
||||
'is_generating': False,
|
||||
'is_unverified': False,
|
||||
'download_url': 'www.google.com',
|
||||
'is_pdf_certificate': True,
|
||||
'uuid': cert.verify_uuid
|
||||
}
|
||||
)
|
||||
@@ -202,6 +203,7 @@ class CertificateDownloadableStatusTests(WebCertificateTestMixin, ModuleStoreTes
|
||||
user_id=self.student.id,
|
||||
course_id=self.course.id,
|
||||
),
|
||||
'is_pdf_certificate': False,
|
||||
'uuid': cert_status['uuid']
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1136,7 +1136,7 @@ def _downloadable_certificate_message(course, cert_downloadable_status):
|
||||
course_id=course.id, uuid=cert_downloadable_status['uuid']
|
||||
)
|
||||
)
|
||||
elif not cert_downloadable_status['download_url']:
|
||||
elif not cert_downloadable_status['is_pdf_certificate']:
|
||||
return GENERATING_CERT_DATA
|
||||
|
||||
return _downloadable_cert_data(download_url=cert_downloadable_status['download_url'])
|
||||
|
||||
@@ -18,6 +18,7 @@ from django.test.client import RequestFactory
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
from openedx.features.learner_profile.toggles import REDIRECT_TO_PROFILE_MICROFRONTEND
|
||||
from openedx.features.learner_profile.views.learner_profile import learner_profile_context
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
|
||||
from openedx.core.djangoapps.waffle_utils.testutils import override_waffle_flag
|
||||
from student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
@@ -269,3 +270,28 @@ class LearnerProfileViewTest(SiteMixin, UrlResetMixin, ModuleStoreTestCase):
|
||||
profile_username = self.user.username
|
||||
context = learner_profile_context(request, profile_username, user_is_staff)
|
||||
self.assertIn('achievements_fragment', context)
|
||||
|
||||
@mock.patch.dict(settings.FEATURES, {'CERTIFICATES_HTML_VIEW': True})
|
||||
def test_certificate_visibility_with_no_cert_config(self):
|
||||
"""
|
||||
Verify that certificates are not displayed until there is no active
|
||||
certificate configuration.
|
||||
"""
|
||||
# Add new certificate
|
||||
cert = self._create_certificate(enrollment_mode=CourseMode.VERIFIED)
|
||||
cert.download_url = ''
|
||||
cert.save()
|
||||
|
||||
response = self.client.get('/u/{username}'.format(username=self.user.username))
|
||||
self.assertNotContains(
|
||||
response, u'card certificate-card mode-{cert_mode}'.format(cert_mode=CourseMode.VERIFIED)
|
||||
)
|
||||
|
||||
course_overview = CourseOverview.get_from_id(self.course.id)
|
||||
course_overview.has_any_active_web_certificate = True
|
||||
course_overview.save()
|
||||
|
||||
response = self.client.get('/u/{username}'.format(username=self.user.username))
|
||||
self.assertContains(
|
||||
response, u'card certificate-card mode-{cert_mode}'.format(cert_mode=CourseMode.VERIFIED)
|
||||
)
|
||||
|
||||
@@ -44,7 +44,10 @@ class LearnerAchievementsFragmentView(EdxFragmentView):
|
||||
course_overview = CourseOverview.get_from_id(course_key)
|
||||
course_certificate['course'] = course_overview
|
||||
if certificates_viewable_for_course(course_overview):
|
||||
passing_certificates.append(course_certificate)
|
||||
# add certificate into passing certificate list only if it's a PDF certificate
|
||||
# or there is an active certificate configuration.
|
||||
if course_certificate['is_pdf_certificate'] or course_overview.has_any_active_web_certificate:
|
||||
passing_certificates.append(course_certificate)
|
||||
except CourseOverview.DoesNotExist:
|
||||
# This is unlikely to fail as the course should exist.
|
||||
# Ideally the cert should have all the information that
|
||||
|
||||
Reference in New Issue
Block a user