Improving logging over generate cert button on progress page.
EDUCATOR-2017.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
The public API for certificates.
|
||||
"""
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
from pytz import UTC
|
||||
@@ -9,6 +10,7 @@ from certificates.models import CertificateWhitelist
|
||||
from openedx.core.djangoapps.certificates.config import waffle
|
||||
from student.models import CourseEnrollment
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
SWITCHES = waffle.waffle()
|
||||
|
||||
@@ -56,10 +58,33 @@ def is_certificate_valid(certificate):
|
||||
|
||||
def can_show_certificate_message(course, student, course_grade, certificates_enabled_for_course):
|
||||
is_whitelisted = CertificateWhitelist.objects.filter(user=student, course_id=course.id, whitelist=True).exists()
|
||||
auto_cert_gen_enabled = auto_certificate_generation_enabled()
|
||||
has_active_enrollment = CourseEnrollment.is_enrolled(student, course.id)
|
||||
certificates_are_viewable = certificates_viewable_for_course(course)
|
||||
|
||||
# Adding a temporary logging for EDUCATOR-2017.
|
||||
if unicode(course.id) == u'course-v1:RITx+PM9004x+3T2017':
|
||||
log.info(
|
||||
(
|
||||
u'can_show_certificate_message called with:'
|
||||
u'course:%s, student: %s, course grade: %s,'
|
||||
u'certificates_enabled_for_course: %s, certificates_viewable_for_course: %s, auto_cert_gen_enabled: %s,'
|
||||
u'has_active_enrollment: %s, passed: %s, is_whitelisted: %s'
|
||||
),
|
||||
course.id,
|
||||
student.username,
|
||||
course_grade,
|
||||
certificates_enabled_for_course,
|
||||
certificates_are_viewable,
|
||||
auto_cert_gen_enabled,
|
||||
has_active_enrollment,
|
||||
course_grade.passed,
|
||||
is_whitelisted
|
||||
)
|
||||
if not (
|
||||
(auto_certificate_generation_enabled() or certificates_enabled_for_course) and
|
||||
CourseEnrollment.is_enrolled(student, course.id) and
|
||||
certificates_viewable_for_course(course) and
|
||||
(auto_cert_gen_enabled or certificates_enabled_for_course) and
|
||||
has_active_enrollment and
|
||||
certificates_are_viewable and
|
||||
(course_grade.passed or is_whitelisted)
|
||||
):
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user