Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lms/djangoapps/certificates/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django.core.exceptions import ObjectDoesNotExist
from opaque_keys.edx.keys import CourseKey

from lms.djangoapps.certificates.models import CertificateWhitelist
from lms.djangoapps.utils import _get_key

from .models import GeneratedCertificate
Expand All @@ -25,6 +26,10 @@ def invalidate_certificate(self, user_id, course_key_or_id):
Invalidate the user certificate in a given course if it exists.
"""
course_key = _get_key(course_key_or_id, CourseKey)
if CertificateWhitelist.objects.filter(user=user_id, course_id=course_key, whitelist=True).exists():
log.info(f'User {user_id} is on the allowlist for {course_key}. The certificate will not be invalidated.')
return False

try:
generated_certificate = GeneratedCertificate.objects.get(
user=user_id,
Expand Down
4 changes: 4 additions & 0 deletions lms/djangoapps/certificates/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def _listen_for_failing_grade(sender, user, course_id, grade, **kwargs): # pyli
if it is currently passing,
downstream signal from COURSE_GRADE_CHANGED
"""
if CertificateWhitelist.objects.filter(user=user, course_id=course_id, whitelist=True).exists():
log.info('{course_id} is using allowlist certificates, and the user {user_id} is on its allowlist. The '
'failing grade will not affect the certificate.'.format(course_id=course_id, user_id=user.id))
return
cert = GeneratedCertificate.certificate_for_student(user, course_id)
if cert is not None:
if CertificateStatuses.is_passing_status(cert.status):
Expand Down