From 1b774d15aa27c6c2a794d3cafd16d6dd0ad2e09d Mon Sep 17 00:00:00 2001 From: ayub-khan Date: Tue, 5 Dec 2017 13:57:46 +0500 Subject: [PATCH] -Allow staff to preview certificates before course end --- lms/djangoapps/certificates/tests/test_webview_views.py | 2 +- lms/djangoapps/certificates/views/webview.py | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/lms/djangoapps/certificates/tests/test_webview_views.py b/lms/djangoapps/certificates/tests/test_webview_views.py index f349d122e0..cfae554322 100644 --- a/lms/djangoapps/certificates/tests/test_webview_views.py +++ b/lms/djangoapps/certificates/tests/test_webview_views.py @@ -658,7 +658,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase): self.assertIn("We cannot find a certificate with this URL or ID number.", response.content) @override_settings(FEATURES=FEATURES_WITH_CERTS_ENABLED) - def test_html_view_for_non_viewable_certificate(self): + def test_html_view_for_non_viewable_certificate_and_for_student_user(self): """ Tests that Certificate HTML Web View returns "Cannot Find Certificate" if certificate is not viewable yet. """ diff --git a/lms/djangoapps/certificates/views/webview.py b/lms/djangoapps/certificates/views/webview.py index 4f430669a8..8476ba46fb 100644 --- a/lms/djangoapps/certificates/views/webview.py +++ b/lms/djangoapps/certificates/views/webview.py @@ -350,7 +350,7 @@ def _get_user_certificate(request, user, course_key, course, preview_mode=None): verify_uuid=unicode(uuid4().hex), modified_date=modified_date ) - else: + elif certificates_viewable_for_course(course): # certificate is being viewed by learner or public try: user_certificate = GeneratedCertificate.eligible_certificates.get( @@ -516,13 +516,6 @@ def render_html_view(request, user_id, course_id): log.info(error_str, course_id, user_id, str(exception)) return _render_invalid_certificate(course_id, platform_name, configuration) - if not certificates_viewable_for_course(course): - log.info( - "Invalid cert: Certificate for %s is not viewable yet.", - course_id, - ) - return _render_invalid_certificate(course_id, platform_name, configuration) - # Kick the user back to the "Invalid" screen if the feature is disabled for the course if not course.cert_html_view_enabled: log.info(